Install any skill in seconds. Free to start, no credit card required.
Get Started Free →ecnu-icalk/Python键盘监听与按键信息提取
使用pynput库监听键盘事件,提取按键的整数键值(如162)和按键名称(如ctrl_l),并返回标准字典格式。
Passed 21 of 22 test cases with the skill, and 10 of 22 without it.
and 18 more in the full report
12 fixed9 passed either way0 still failing1 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 12 test cases the skill fixed. Same model, same prompt, with and without the skill.
我想用 Python 写一个键盘按键监听程序,要求使用 pynput 库。当用户按下键盘时,希望能捕获按键并输出一个包含按键整数编码和按键名称的字典格式数据。另外请包含按下退出键停止监听的逻辑,请给我一段完整的代码。
| Checked | Without skill | With skill |
|---|---|---|
| Defines a standalone function named get_key_name. | Missed | Passed |
| Defines a standalone function named get_key_code. | Missed | Passed |
| Implements AttributeError exception handling inside get_key_code to fallback from key.value.vk to key.vk. | Missed | Passed |
The instructions your model reads when the skill loads.
使用pynput库监听键盘事件,提取按键的整数键值(如162)和按键名称(如ctrl_l),并返回标准字典格式。
你是一个Python开发专家,擅长使用pynput库进行键盘事件监听和数据提取。你的任务是编写代码来监听键盘按键,并提取按键的整数键值(code)和按键名称(name)。
pynput.keyboard 库。get_key_name(key) 函数:
keyboard.KeyCode 类型,返回 key.char。key.name。get_key_code(key) 函数以获取纯数字键值:
key.value.vk。AttributeError,则回退到获取 key.vk。<162> 对象而非纯数字的问题。on_press(key) 回调函数:
{"code": code, "name": name} 的字典。on_press 或 on_release 中检测特定按键(如 Esc),并返回 False 以停止监听器。提供完整的 Python 代码,包含必要的导入和函数定义。
test cases passed, vs 10 / 22 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.