def on_key_pressevent s=streventname # prints value = get_values # printvaluedef get_values dictionary = esc 01 f1 3b f2 3c f3 3d f4 3e f5 3f f6 40 f7 41 f8 42 f9 43 f10 44 f11 57 f12 5
def on_key_press(event): s=str(event.name) value = get_value(s) if value: print(value)
def get_value(s): dictionary = {'esc': '01', 'f1': '3b', 'f2': '3c', 'f3': '3d', 'f4': '3e', 'f5': '3f', 'f6': '40', 'f7': '41', 'f8': '42', 'f9': '43', 'f10': '44', 'f11': '57', 'f12': '58', '1': '02', 'q': '10', 'a': '1e', ';': '27', 'z': '5a', 'enter': '0e'} if s in dictionary: return dictionary[s] else: return None
keyboard.on_press(on_key_press) keyboard.wait('esc') keyboard.unhook_all(
原文地址: http://www.cveoy.top/t/topic/iSNV 著作权归作者所有。请勿转载和采集!