I\'m interested in seeing if it\'s possible to bind functions to a user pressing/releasing a key on the keyboard.
So far, I\'ve been able to get key press events wit
On a Linux desktop, you can pipe the output of the 'xev' command into your module, and then parse the stream to emit your own 'keyup' and 'keydown' events. Less portable than SDL perhaps, but more straightforward. There's a module to do this. (Disclaimer: I wrote it).
const xevEmitter = require('xev-emitter')(process.stdin)
xevEmitter.on('KeyPress', (key) => {
console.log(key, 'was pressed')
})
xevEmitter.on('KeyRelease', (key) => {
console.log(key, 'was released')
})
Executing:
$ xev | node example.js
h was pressed
h was released