📄 testkeyboard.c
字号:
/**************************start***********************/
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <asm/delay.h>
main()
{
int fd;
char key = 0;
fd = open("/dev/button", O_RDWR);
if (fd == -1)
{
printf("open device button errr!\n");
return 0;
}
ioctl(fd, 0, 0); //清空键盘缓冲区, 后面两个参数没有意义,
while(key != 16)
{
if (read(fd, &key, 1) > 0)
{
printf("*********************Key Value = %d*****************************\n", key);
}
}
close(fd);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -