先getch一下得到a,如果等于0或者224,就说明是功能键,再getch下一个得到b,那么这个功能键的扫描码就是a+(b*256) 。
可以看看下面这个例子:
import msvcrt while 1: if msvcrt.kbhit(): # Key pressed a = ord(msvcrt.getch()) # get first byte of keyscan code if a == 0 or a == 224: # is it a function key b = ord(msvcrt.getch()) # get next byte of key scan code x = a + (b*256) # cook it. return x # return cooked scancode else: return a # else return ascii code
希望本文所述对大家的Python程序设计有所帮助。
声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论