Linux 上的键码表
keyboad key codes table on Linux
我正在学习C++。
我正在测试哪个键如何按下用户。我写了这段代码:
#include <signal.h>
#include <termios.h>
#include <stdio.h>
#include <math.h>
#define KEYCODE_L 0x44 // Left Arrow Key
#define KEYCODE_R 0x43 // Right Arrow Key
#define KEYCODE_U 0x41 // Up Arrow Key
#define KEYCODE_D 0x42 // Down Arrow Key
#define KEYCODE_Q 0x71 // Q Key
int main(int argc, char **argv)
{
// get the console in raw mode
tcgetattr(kfd, &cooked);
memcpy(&raw, &cooked, sizeof(struct termios));
raw.c_lflag &= ~(ICANON | ECHO);
// Setting a new line, then end of file
raw.c_cc[VEOL] = 1;
raw.c_cc[VEOF] = 2;
tcsetattr(kfd, TCSANOW, &raw);
puts("Reading from keyboard");
puts("---------------------------");
puts("Use arrow keys to move the robot.");
// get the next event from the keyboard
if (read(kfd, &c, 1) < 0)
{
perror("read():");
/**
* Reset console to its original mode.
*/
tcsetattr(kfd, TCSANOW, &cooked);
exit(-1);
}
switch (c)
{
case KEYCODE_R:
std::cout << "Right Arrow" << std::endl;
break;
case KEYCODE_L:
std::cout << "Left Arrow" << std::endl;
break;
case KEYCODE_U:
std::cout << "Up Arrow" << std::endl;
break;
case KEYCODE_D:
std::cout << "Down Arrow" << std::endl;
break;
}
}
在哪里可以找到我KEYCODE_调用的所有值的表?
我正在寻找一个包含所有键值的表。我找到了一个 JavaScript 表,但值不匹配。
这些是终端给你的 Ascii 代码。您可以通过在 Linux 中使用showkey -a
命令来查看它们。
有关此命令的详细信息,请参阅手册页和联机,例如 https://linux.die.net/man/1/showkey
相关文章:
- luaL_dofile在已知良好的字节码上失败,可以使用未编译的版本
- 位移操作和位掩码未检测到重复字符
- OpenCV - 带有掩码的absdiff
- 有没有办法区分Qt小部件是通过鼠标单击还是通过按表键获得焦点?
- 生成前缀位掩码
- 如何解释C++字符串中的 \u 转义码?
- 在CRC-16 CCITT中将数据从二进制解码为文本,我应该输入一个码字,使用CRC生成器进行编码
- q网络回复 无状态码或错误,但失败
- 将Wiimote MAC地址转换为PIN码,从C++转换为Python或Javascript
- 有没有办法获取用户操作系统的ANSI转义码?
- 需要左键作为赋值的左操作数?? 在链表中添加Add_End、删除和Delete_Front?
- 如何从__m64值的 lsb 创建 8 位掩码?
- Linux 上的键码表
- 如何从C++验证Lua表键
- "Windows"按钮的C++键扫描码是什么?
- 在lua c++中访问由表键索引的表
- linux下的键码是否一致?
- 虚拟键码到unicode的映射受写入std::cout的影响
- 编辑/删除受保护的注册表键值
- 哈希表键与值获取复杂度