Class KeyStore
Index
Constructors
Methods
Constructors
constructor
- new KeyStore(
keyNames?: Iterable<string, any, any>,
options?: KeyStoreOptions,
): KeyStore Parameters
Optional
keyNames: Iterable<string, any, any>Optional
options: KeyStoreOptionsOptional parameters
Returns KeyStore
Methods
Protected
_updateSubscribers
addKey
anyPressed
- anyPressed(keys?: string | Iterable<string, any, any>): 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
keydown
- keydown(event: KeyboardEvent): void
Handle keydown event adding any key from the tracked key set.
Parameters
- event: KeyboardEvent
KeyboardEvent.
Returns void
- event: KeyboardEvent
keysPressed
- keysPressed(): IterableIterator<string, any, any>
Returns IterableIterator<string, any, any>
Returns current pressed keys iterator.
keysTracked
- keysTracked(): IterableIterator<string, any, any>
Returns IterableIterator<string, any, any>
Returns currently tracked keys iterator.
keyup
- keyup(event: KeyboardEvent): void
Handle keyup event removing any key from the tracked key set.
Parameters
- event: KeyboardEvent
KeyboardEvent.
Returns void
- event: KeyboardEvent
removeKey
setOptions
- setOptions(options: KeyStoreOptions): void
Update options.
Parameters
- options: KeyStoreOptions
Options to set.
Returns void
- options: KeyStoreOptions
subscribe
- subscribe(handler: Subscriber<KeyStore>): 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.