从Shell输入中检测元(特殊)键(Ctrl,Shift,Alt,Tab,Esc,Backspace) [英] Detect meta (special) keys (Ctrl, Shift, Alt, Tab, Esc, Backspace) from Shell Input

查看:84
本文介绍了从Shell输入中检测元(特殊)键(Ctrl,Shift,Alt,Tab,Esc,Backspace)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人知道如何检测元(特殊)密钥 ( Ctrl Shift Alt Tab Esc 退格键).

I want to know if anybody knows how to detect meta (special) keys (Ctrl, Shift, Alt, Tab, Esc, Backspace) from Shell Input.

我看过一些文章,这些文章解释了如何检测箭头键等,但是没有上面的特殊键.
我有什么办法可以做$ showkey -s并使用原始扫描代码以某种方式获取键输入?

I've seen posts that explain how to detect arrow keys and such, but not the above special keys.
Is there any way I can do $ showkey -s and use the raw scan-code to somehow get the key input?

任何帮助将不胜感激!

推荐答案

通常,您不能这样做.那说:

In general, you cannot do it. That said:

  • X11发送KeyPressKeyRelease事件.
  • Linux控制台提供了一组ioctl,这些ioctl允许对键盘的低级别访问,如console_ioctl(4)所述.您可以将键盘设置为RAW或MEDIUMRAW模式(不要将这些模式与termios的原始模式混淆,它们根本没有关联.)
  • X11 sends KeyPress and KeyRelease events.
  • The Linux console provides a set of ioctls that allow low-level access to the keyboard, documented at console_ioctl(4). You would set the keyboard to RAW or MEDIUMRAW mode (don't confuse these modes with termios' raw mode, they are not related at all).

这篇关于从Shell输入中检测元(特殊)键(Ctrl,Shift,Alt,Tab,Esc,Backspace)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆