node-keys-down
Check what keys are down with a simple API
installation
npm install node-keys-down
require('node-keys-down').start()
Start detecting keyboard activity. Call this method before the others.
It returns a function that ends detecting keyboard activity.
const keysDown = const end = keysDownstart // ... your code
require('node-keys-down').isPressed(key)
Returns true
if key
is pressed. The key code looks like what you might see in event.key
.
const keysDown = keysDownstart // ... const playerMovingLeft = keysDownconst playerRunning = keysDownconst playerShooting = keysDownconst playerUsing = keyDown || keysDown
require('node-keys-down').keysPressed()
Returns an array with the names of all keys which are currently pressed.
const keysDown = keysDownstart // ... console