Class KeyStore
Index
Constructors
Methods
Constructors
constructor
- new
Key (keyNames?, options?): KeyStoreStore Parameters
Optional
keyNames: Iterable<string, any, any>Optional
options: KeyStoreOptionsOptional parameters
Returns KeyStore
Methods
Protected
_updateSubscribers
addKey
anyPressed
- any
Pressed (keys?): boolean Returns true if any of given keys are pressed. If
keys
is undefined then the result is true if any keys being tracked are pressed.Parameters
Optional
keys: 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
isPressed
- is
Pressed (keys): boolean 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
- keydown(event): void
Handle keydown event adding any key from the tracked key set.
Parameters
- event: KeyboardEvent
KeyboardEvent.
Returns void
- event: KeyboardEvent
keysPressed
- keys
Pressed (): IterableIterator<string, any, any> Returns IterableIterator<string, any, any>
Returns current pressed keys iterator.
keysTracked
- keys
Tracked (): IterableIterator<string, any, any> Returns IterableIterator<string, any, any>
Returns currently tracked keys iterator.
keyup
- keyup(event): void
Handle keyup event removing any key from the tracked key set.
Parameters
- event: KeyboardEvent
KeyboardEvent.
Returns void
- event: KeyboardEvent
removeKey
setOptions
- set
Options (options): void Update options.
Parameters
- options: KeyStoreOptions
Options to set.
Returns void
- options: KeyStoreOptions
subscribe
- subscribe(handler): Unsubscriber
Parameters
- handler: Subscriber<KeyStore>
Callback function that is invoked on update / changes.
Returns Unsubscriber
Unsubscribe function.
- handler: Subscriber<KeyStore>
Provides a readable store to track keys actively pressed. KeyStore is designed to be used with the keyforward action.