Skip to content

Instantly share code, notes, and snippets.

@ednisley
Last active June 14, 2021 07:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ednisley/2b2be1b48dbb01446602 to your computer and use it in GitHub Desktop.
Save ednisley/2b2be1b48dbb01446602 to your computer and use it in GitHub Desktop.
Python Source Code: Raspberry Pi USB Numeric Keypad -- evdev test
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
@ednisley
Copy link
Author

More details on my blog at http://wp.me/poZKh-5DL

@woodie
Copy link

woodie commented Jun 14, 2021

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