菜鸟学Python(8):功能键的读取
2007-04-05 21:22
399 查看
我知道怎么读取功能键了。先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
可以看看下面这个例子:
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(8):功能键的读取
- python菜鸟笔记--python读取和写入CSV文件操作
- python菜鸟笔记--python读取和写入txt文件的方法
- Python功能键的读取方法
- Python功能键的读取方法
- 第3章 python3基础 文件的读取与显示 例子
- python3.3:文本文件读取、处理及保存。小练习
- python3读取HDA零售企业数据(一)
- python之批量读取文件
- Python 读取文件的多种方式
- 【Python】从文件中读取数据
- Python 打开文件读取每行数据
- Python菜鸟初体验--纠结的工具选择
- Python实现读取TXT文件数据并存进内置数据库SQLite3的方法
- python中读取xml文件的库
- Python3 将configparser从ini文件中读取的内容转换成字典格式
- python读取写入文件
- 【SVM之菜鸟实现】 python版
- 【Python图像处理】图片读取/提取直方图
- python读取配置文件 ConfigParser