Advertisement
joanmarie

a11y key event listener

Apr 10th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import pyatspi
  4.  
  5. def onKey(e):
  6.     if e.type == pyatspi.KEY_PRESSED_EVENT:
  7.         typeString = '>>> KEY PRESSED'
  8.     elif e.type == pyatspi.KEY_RELEASED_EVENT:
  9.         typeString = '<<< KEY RELEASED'
  10.     print '%s: %s' % (typeString, e.event_string)
  11.  
  12. pyatspi.Registry.registerKeystrokeListener(
  13.     onKey,
  14.     mask=range(256),
  15.     kind=(pyatspi.KEY_PRESSED_EVENT, pyatspi.KEY_RELEASED_EVENT))
  16. pyatspi.Registry.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement