I need to listen to the raw commands/keypresses that a bluetooth keyboard sends to my device and if possible, prevent them from 'propagating' to the rest of the system.
Basically, I've written something with Node.js and coffee-script that receives keypresses from stdin
and controls my Philips Hue lightbulbs. It looks something like this:
keypress = require 'keypress'
# Setup keypress events
keypress process.stdin
process.stdin.on 'keypress', (character, key) ->
switch character
when 'l' then hue.decreaseTemp()
when 'r' then hue.increaseTemp()
when 'u' then hue.increaseBri()
when 'd' then hue.decreaseBri()
when 'b' then hue.turnOff()
# Exit on ctrl-c
if key?.ctrl and key.name is 'c'
process.stdin.pause()
It's functionality works, but it's not very useful as it receives input from stdin, preventing it from running in the background.
What could I do to make this receive input without the window having focus?
My preference is for something in Node.js or Python to run on my Mac, but I'm willing to switch languages or run on my Raspberry Pi if need be