Keyboard.js
KeyboardManager
Manages the keyboard input.
Kind: global class
Constructors:
- KeyboardManager
- .getNameByKeyCode(keyCode) ⇒
string
- .getKeyCodeByName(name) ⇒
number
- .isKeyPressed(key) ⇒
boolean
- .isKeyPressedName(name) ⇒
boolean
- .isKeyPressedKeyCode(keyCode) ⇒
boolean
- .getNameByKeyCode(keyCode) ⇒
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.
Param | Type | Description |
---|---|---|
keyCode | number | 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.
Param | Type | Description |
---|---|---|
name | string | 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.
Param | Type | Description |
---|---|---|
key | number | 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.
Param | Type | Description |
---|---|---|
name | string | 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.
Param | Type | Description |
---|---|---|
keyCode | number | The key code of the key. |
Example
Impacto.Inputs.KeyboardManager.isKeyPressedKeyCode(37); // true