Programmatically call all callbacks as if a key was pressed.
Programmatically call all callbacks as if a key was lifted.
Clear a callback listening for any key. If no callback is provided, will clear all callbacks on listening for any keys.
If no existing event is provided, will clear all
Clear a callback listening for any key. If no callback is provided, will clear all callbacks on listening for any keys.
If no existing event is provided, will clear all
Clear an existing callback for a key. If no callback is provided, will clear all callbacks on that key.
KeyCode - The keycode to clear onDown.
If no existing event is provided, will clear all
Clear an existing callback for a key. If no callback is provided, will clear all callbacks on that key.
KeyCode - The keycode to clear onUp.
If no existing event is provided, will clear all
Fires callback on any key down. Can call multiple times to register multiple callbacks.
(KeyHandlerEvent) => void - The callback
Fires callback on any key up. Can call multiple times to register multiple callbacks.
(KeyHandlerEvent) => void - The callback
Fires callback on a specific key down. Can call multiple times to register multiple callbacks.
KeyCode | number - The Key to monitor
(KeyHandlerEvent) => void - The callback
Fires callback on a specific key up. Can call multiple times to register multiple callbacks.
KeyCode | number - The Key to monitor
(KeyHandlerEvent) => void - The callback
Generated using TypeDoc
KeyboardContext represents a single 'mode' of the game's keyboard controls. For instance, you might have one context to use for the overworld, another for menus, another for inventory, etc.
You can set the active context through a KeyboardHandler's setContext(ctx) and clearContext() methods.
Normally the onDown/onUp callbacks can be used to listen for specific keys, but for more control onAnyDown/onAnyUp can be used to register callbacks that fire on any key press. These 'any' callbacks will always be the first to be called during a new key press.
You can register multiple 'any' callbacks or key-specific callbacks for rare patterns,for instance registering 2 callbacks to fire when the 'E' key is pressed, etc.