Last active
June 14, 2021 07:54
-
-
Save ednisley/2b2be1b48dbb01446602 to your computer and use it in GitHub Desktop.
Python Source Code: Raspberry Pi USB Numeric Keypad -- evdev test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from evdev import InputDevice,ecodes,KeyEvent | |
k=InputDevice('/dev/input/keypad') | |
for e in k.read_loop(): | |
if (e.type == ecodes.EV_KEY) and (KeyEvent(e).keystate == 1): | |
if (KeyEvent(e).keycode == 'KEY_NUMLOCK'): | |
continue # we don't care about the NumLock state | |
else: | |
print KeyEvent(e).scancode, KeyEvent(e).keycode |
I was thinking about wiring up a matrix keypad (to some free GPIO pins) for my MIDI keyboard project, but your blog post inspired me to invest a bit more energy int the USB keypad.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More details on my blog at http://wp.me/poZKh-5DL