Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Hotkey python


from pynput import keyboard
  
cmb = [{keyboard.Key.shift, keyboard.Key(char='a')},{keyboard.Key.shift, keyboard.Key(char='A')}]
  
current = set()
  
def execute():
  print("Detected hotkey")
  
def on_press(key):
  if any([key in z for z in cmb]):
    current.add(key)
    if any(all(k in current for k in z) for z in cmb):
      execute()
  
def on_release(key):
  if any([key in z for z in cmb]):
    current.remove(key)
  
with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
  listener.join()
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Hotkey #python
ADD COMMENT
Topic
Name
1+8 =