I need to listen to the raw commands / keystrokes that the Bluetooth keyboard sends to my device, and if possible, prevent them from โspreadingโ to the rest of the system.
Basically, I wrote something with Node.js and a coffee script that receives keystrokes from stdin and controls Philips Hue bulbs. 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()
This function works, but it is not very useful, as it receives input from stdin, preventing it from running in the background.
What can I do to make this input input without the focus of the window?
My preference is for something in Node.js or Python to run on my Mac, but I'm ready to switch languages โโor run my raspberry Pi if you need to
Josh hunt
source share