全局密钥绑定变得简单
keybind的Python项目详细描述
https://github.com/idlesign/keybind
说明
使全局密钥绑定变得简单
需要x11(x窗口系统)。对于类Unix系统,例如Linux。
既可以用作python包,也可以从cli中使用。
功能:
- 为函数创建一些全局键绑定。
- 在gui或cli应用程序中使用它们。
- 使用cli将运行的任意程序绑定到密钥。
来自python
fromkeybinderimportKeyBinderdefdo():print('done')# The following will start key listening loop in a thread# (useful if you don't want to block your main program).KeyBinder.activate({'Ctrl-K':do,'Shift-R':None,# Do not run anything, just intercept.},run_thread=True)
来自cli
; Listen to Ctrl-K, Ctrl-R and D (keycode 40). ; Provide as many -k as you want. $ keybind -k "Ctrl-K=ls -lah" -k "Ctrl-R=python run.py somearg --someopt" -k "40=date"; All keys interception mode. Show keycodes. ; Use wisely, keep your mouse ready. $ keybind --sniff