Skip to content

keyboard.input overview


Table of contents


utils

KeyboardInput (class)

A main keyboard input: it does not have own key bindings, but provides an API to bind keys. It is responsible for listening key up/down events (when running!) and emit the events to subscribers. Every World entity has its own dedicated instance of Keyboard input, which is running only when the world is running

Signature

export declare class KeyboardInput {
  constructor()
}

startInternal (method)

Signature

protected startInternal()

stopInternal (method)

Signature

protected stopInternal()

bind (method)

Creates an observable that emits a boolean whenever a key with the given code is pressed or released

Signature

bind(code: string): Observable<boolean>

bindMany (method)

Creates an observable that emits a boolean indicating whether any of the keys with the given codes are pressed or released. Should be used when you have more than one keys, responsible for the same action.

Signature

bindMany(...codes: string[]): Observable<boolean>

emulateKeyDown (method)

Emulates a key down event for the given key code

Signature

emulateKeyDown(code: string): void

emulateKeyUp (method)

Emulates a key up event for the given key code

Signature

emulateKeyUp(code: string): void

emulateKeyPress (method)

Emulates a key press event (down and up) for the given key code

Signature

emulateKeyPress(code: string): void

handleKeys (method)

Signature

private handleKeys(e: KeyboardEvent)

onPointerLockChange (method)

Signature

private onPointerLockChange()

resetAllKeys (method)

Signature

public resetAllKeys()

skipKeyDownsOnExternalFocus (property)

Flag which disables handling key downs, when document has some "typeable" element focused

Signature

skipKeyDownsOnExternalFocus: boolean

externalFocusBlacklist (property)

Which element types should filter key downs when focused

Signature

externalFocusBlacklist: (new () => HTMLElement)[]