Class KeyStore
Index
Constructors
Methods
Constructors
constructor
Parameters
OptionalkeyNames: Iterable<string>Optionaloptions: KeyStoreOptionsOptional parameters
Returns KeyStore
Methods
Protected_updateSubscribers
ProtectedUpdates subscribers.
Returns void
addKey
Add given key to the tracking key set.
Parameters
- key: string
Key to add.
Returns void
- key: string
anyPressed
Returns true if any of given keys are pressed. If
keysis undefined then the result is true if any keys being tracked are pressed.Parameters
Optionalkeys: string | Iterable<string, any, any>Zero or more key strings or list to verify if any pressed.
Returns boolean
True if any keys set are pressed.
hasKey
Is the given key in the tracking key set.
Parameters
- key: string
Key to check.
Returns void
- key: string
isPressed
Returns true if all given keys are pressed.
Parameters
- keys: string | Iterable<string, any, any>
One or more key strings to verify if pressed.
Returns boolean
Are all keys pressed.
- keys: string | Iterable<string, any, any>
keydown
Handle keydown event adding any key from the tracked key set.
Parameters
- event: KeyboardEvent
KeyboardEvent.
Returns void
- event: KeyboardEvent
keysPressed
Returns IterableIterator<string>
Returns current pressed keys iterator.
keysTracked
Returns IterableIterator<string>
Returns currently tracked keys iterator.
keyup
Handle keyup event removing any key from the tracked key set.
Parameters
- event: KeyboardEvent
KeyboardEvent.
Returns void
- event: KeyboardEvent
removeKey
Remove the given key from the tracking key set.
Parameters
- key: string
Key to remove.
Returns void
- key: string
setOptions
subscribe
Parameters
- handler: Subscriber<KeyStore>
Callback function that is invoked on update / changes.
Returns Unsubscriber
Unsubscribe function.
- handler: Subscriber<KeyStore>
value
Parameters
- key: string
key or key code to lookup.
Returns number
1 if currently pressed and 0 if not pressed.
- key: string
Provides a readable store to track keys actively pressed. KeyStore is designed to be used with the keyforward action.