new Keyboard()
Creates keyboard instance which handles chip8 input.
- Source:
Members
-
<static> Keyboard.CHIP8_KEYS :Object
-
Maps chip8 keys to PC keys. Populated in constructor.
Type:
- Object
- Source:
-
<static> Keyboard.PC_KEY_MAP :Object
-
Maps PC keys to chip8 keys.
Type:
- Object
- Source:
Properties:
Name Type Default Description "88"
Object 0 "49"
Object 1 "50"
Object 2 "51"
Object 3 "81"
Object 4 "87"
Object 5 "69"
Object 6 "65"
Object 7 "83"
Object 8 "68"
Object 9 "90"
Object A "67"
Object B "52"
Object C "82"
Object D "70"
Object E "86"
Object F
Methods
-
isKeyPressed(key) → {boolean}
-
Checks if given key is pressed.
Parameters:
Name Type Description key
number key number (0x0 - 0xF)
- Source:
Returns:
true if key is pressed, false otherwise
- Type
- boolean
-
keyDown(chip8Key)
-
Simulates key down.
Parameters:
Name Type Description chip8Key
number key number (0x0 - 0xF)
- Source:
-
keyUp(chip8Key)
-
Simulates key up.
Parameters:
Name Type Description chip8Key
number key number (0x0 - 0xF)
- Source:
-
onNextKeyPressed(chip8Key)
-
This method is called and set to NOP after each key down.
Parameters:
Name Type Description chip8Key
number pressed key number (0x0 - 0xF)
- Source:
-
reset()
-
Resets keyboard state.
- Source: