from pynput import keyboard
def my_hot_key():
print("Message")
def on_release(key):
keys = str(key)
if keys == "'q'":
my_hot_key()
else:
pass
try:
with keyboard.Listener(
on_release=on_release) as listener:
listener.join()
except:
pass