按 F1 时中文键盘返回不同的键码

按 F1 时中文键盘返回不同的键码

由于我没有太多数据,所以我只能简短地介绍一下。

所以我买了一个机械键盘。每次我按 F1,窗口就会失焦。F2 可以。

按 F1 键xev

FocusOut event, serial 48, synthetic NO, window 0x5400001,
    mode NotifyGrab, detail NotifyAncestor

FocusOut event, serial 48, synthetic NO, window 0x5400001,
    mode NotifyWhileGrabbed, detail NotifyNonlinear

FocusIn event, serial 48, synthetic NO, window 0x5400001,
    mode NotifyWhileGrabbed, detail NotifyNonlinear

KeymapNotify event, serial 48, synthetic NO, window 0x0,
    keys:  0   0   0   0   0   0   0   0   8   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

FocusIn event, serial 48, synthetic NO, window 0x5400001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 48, synthetic NO, window 0x0,
    keys:  3   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  

按 F2 键xev

KeyPress event, serial 48, synthetic NO, window 0x5400001,
    root 0x290, subw 0x0, time 45947409, (234,268), root:(235,302),
    state 0x0, keycode 68 (keysym 0xffbf, F2), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
   XFilterEvent returns: False

KeyRelease event, serial 48, synthetic NO, window 0x5400001,
    root 0x290, subw 0x0, time 45947546, (234,268), root:(235,302),
    state 0x0, keycode 68 (keysym 0xffbf, F2), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

所以几乎xev无法识别 F1 键,但可以识别 F2 键。请注意,如果我按 +,它会将其识别为keycode 179 (keysym 0x1008ff81, XF86Tools)。那么也许有办法绑定XF86ToolsF1?我正在运行 Openbox。检查了dconf-editor键绑定,但什么也没有。谢谢。

編輯1:所以我尝试将 F1 绑定到 Openbox 中的某个东西。单独使用 F1 不起作用,但 W-F1 可以。如果我在 XFCE 中打开键盘设置,F1 会注册但不起作用。

答案1

问题解决了!

好吧,经过一段时间的折腾xkeycaps,我决定尝试不同的键盘布局,104 键和 105 键。查看布局后,我发现在 104 键布局中,F1 键绑定到 43。另一方面,105 键将 F1 键绑定到“帮助”。这意味着通过将键盘布局从 105 键更改为 104 键,我可以解决这个问题。

  1. 编辑/etc/default/keyboard。你会发现里面有一行

XKBMODEL="pc105"

改成pc105pc104

  1. 跑步sudo dpkg-reconfigure console-setup

现在可以使用以下方法检测 F1 键xev

相关内容