I was occupied on a project and I found a code that was perfectly what I was searching for, but there are parts that I don't understand could some of you explain me it please? This is the code that I found:
from pynput import keyboard
from pynput.keyboard import Controller
keypress = Controller()
COMBINATIONS = [
{keyboard.KeyCode(char='a'), keyboard.KeyCode(char='z')},
]
current = set()
def execute():
for loop in range(0, 10):
keypress.press('w')
keypress.release('w')
def on_press(key):
if any([key in COMBO for COMBO in COMBINATIONS]): # THIS PART
current.add(key)
print(current)
if any(all(k in current for k in COMBO) for COMBO in COMBINATIONS): #THIS PART
execute()
def on_release(key):
if any([key in COMBO for COMBO in COMBINATIONS]): #THIS PART
current.remove(key)
with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()
I commented the parts that I don't understand with #THIS PART
commend Thanks for helping:)