Skip to main content

Keyboard.js

KeyboardManager

Manages the keyboard input.

Kind: global class
Constructors:

KeyboardManager.getNameByKeyCode(keyCode) ⇒ string

Returns the name of the key by its keyCode.

Kind: static method of KeyboardManager
Returns: string -

The name of the key.

ParamTypeDescription
keyCodenumber

The key code of the key.

Example

const { left } = Impacto.Inputs.KeyboardManager.keys;
console.log(Impacto.Inputs.KeyboardManager.getNameByKeyCode(left)); // left

KeyboardManager.getKeyCodeByName(name) ⇒ number

Returns the key code of the key by its name.

Kind: static method of KeyboardManager
Returns: number -

The key code of the key.

ParamTypeDescription
namestring

The name of the key.

Example

console.log(Impacto.Inputs.KeyboardManager.getKeyCodeByName("left")); // 37

KeyboardManager.isKeyPressed(key) ⇒ boolean

Returns true if the key is pressed.

Kind: static method of KeyboardManager
Returns: boolean -

True if the key is pressed.

ParamTypeDescription
keynumber | string

The key code or name of the key.

Example

const { left } = Impacto.Inputs.KeyboardManager.keys;
Impacto.Inputs.KeyboardManager.isKeyPressed(left); // false

KeyboardManager.isKeyPressedName(name) ⇒ boolean

Returns true if the key is pressed by its name.

Kind: static method of KeyboardManager
Returns: boolean -

True if the key is pressed.

ParamTypeDescription
namestring

The name of the key.

Example

Impacto.Inputs.KeyboardManager.isKeyPressedName("left"); // true

KeyboardManager.isKeyPressedKeyCode(keyCode) ⇒ boolean

Returns true if the key is pressed by its key code.

Kind: static method of KeyboardManager
Returns: boolean -

True if the key is pressed.

ParamTypeDescription
keyCodenumber

The key code of the key.

Example

Impacto.Inputs.KeyboardManager.isKeyPressedKeyCode(37); // true