如何检查是否同时按下两个键?

问题描述 投票:-1回答:1

我现在正在写一个键盘驱动模块。我想同时按下shift键和其他键将小写改为大写。我需要解析扫描码吗?请提供一些提示,我非常感谢您提供示例代码。

linux linux-kernel linux-device-driver
1个回答
0
投票

实际上,键盘的每个键有两种不同的关联 - 按下它(键)时的事件和释放键(键)时的不同事件。您只需要使用这些事件。

对于你的问题,你将不得不做一些事情(采取0为press和1发布):

/*eventA for shift key*/
if (eventA == 0)
{
    Flag = PRESSED;
}
else
{
    Flag = RELEASED;
}

...

/*eventX for any character key*/
if (eventX == 0 )
{
    if (Flag == PRESSED)
        toupper(...)


    //print the character

}
© www.soinside.com 2019 - 2024. All rights reserved.