getchlib is library for reading key presses and assigning hotkeys.
- Full Unicode support
- Blocking and non-blocking key press reading
- Cross-platform support
- Basic hotkeys (
CTRL-VorALT-A) are defined - Not interruptable key press reading support ( cannot be interrupted by
CTRL-C, returns key code instead )
pip install getchlib
import getchlib
key=getchlib.getkey()Waits until user presses a key.
import getchlib
key=getchlib.getkey(False)Returns first key pressed in time specified by its second argument tout ( 0.01 by default ).
import getchlib
key=getchlib.getkey(catch=True)import getchlib
def function():
print('hello')
f=getchlib.HotKeyListener()
f.add_hotkey('ctrl-x',function)
f.start()NOTE:f.start() runs in foreground
import getchlib
def function():
print('hello')
f=getchlib.HotKeyListener(catch=True)
f.add_hotkey('a',function)
f.start()import getchlib
def function():
print('hello')
f=getchlib.HotKeyListener(catch=True)
f.add_hotkey('a',function)
...
f.terminate()getchlib is licensed under GPL License