I want to call functions by pressing hot keys. I want functions to have arguments with values from users. I am using this documentation: Handling the keyboard
Here is a sample of code to illustrate the problem:
from pynput import keyboard
text_1 = 'printing text_1'
def on_activate_p_1( text_1 ):
print( text_1 )
text_2 = 'printing text_2'
def on_activate_p_2( text_2 ):
print( text_2 )
with keyboard.GlobalHotKeys({
'p+1' : on_activate_p_1,
'p+2' : on_activate_p_2
}) as h:
h.join()
When pressing 'p+1', I am getting an error:
TypeError: on_activate_p_1() missing 1 required positional argument: 'text_1'
Question: how to pass arguments to functions used by (global) hot keys?