Следующий код реализует запуск функции при нажатии клавиши 4:
import msvcrt while True: char = msvcrt.getch() if char == b'4': function()
Прошу помощи от более опытных кодеров

Заранее большое спасибо!
import msvcrt while True: char = msvcrt.getch() if char == b'4': function()

import ctypes from ctypes import wintypes import win32con def function(): print("Yahoo!") ctypes.windll.user32.RegisterHotKey (None, 1, 0, 0x72) msg = wintypes.MSG() while ctypes.windll.user32.GetMessageA (ctypes.byref(msg), None, 0, 0) != 0: if msg.message == win32con.WM_HOTKEY: function()
....... msg = wintypes.MSG() while ctypes.windll.user32.GetMessageA (ctypes.byref(msg), None, 0, 0) != 0: if msg.message == win32con.WM_HOTKEY: .......