在linux中模拟Numpad

我的笔记本电脑没有小键盘,甚至连FN键都没有小键盘。

当我使用Windows时,我使用AutoHotkey和脚本,我用789456123替换QWEASDZXC键,如果我想禁用它,只需要键入F12。

有没有办法在linux中做到这一点?

我可以想办法用XKB做几件事,但这不适合胆小的人。

  1. 创建一个自定义符号选项 ,将您的数字添加到所选键的“level3”或“level5”。 ( AltGrISO_Level3_Shift键,在非美国或美国国际布局中用于áçćéñþëd字符。)通常这些键的作用类似于Shift – 您必须在键入数字时按住它们。 但是如果愿意的话,你的新选项可能会使它们更像CapsLock 。 然后,这样的选项将覆盖布局的默认绑定,以便添加数字。

     // emulate numpad on first 3 columns of alphabetic keys // initial key definitions from /usr/share/X11/xkb/symbols/us // ("intl" stanza) partial xkb_symbols "qweasdzxc" { // numbers on level3 (RightAlt chooses lv3) include "level3(ralt_switch)" key  { [ q, Q, 7, division ] }; key  { [ w, W, 8, multiply ] }; key  { [ e, E, 9, minus ] }; // etc ... // OR ... // numbers on level5 (RightCtrl chooses lv5) include "level5(rctrl_switch)" key  { [ q, Q, adiaeresis, Adiaeresis, 7, division ] }; key  { [ w, W, aring, Aring, 8, multiply ] }; key  { [ e, E, eacute, Eacute, 9, minus ] }; // etc ... }; // end "qweasdzxc" // rules to load this as an option ! option = symbols lv3:qweasdzxc = +filename(qweasdzxc) // load from commandline. may need -I/path/to/custom/xkb setxkbmap -layout us -option lv3:qweasdzxc 
  2. 创建一个空布局,仅发出这些键上的那些数字,而不发出其他字母数字符号。 当作为第二个布局加载时,您将拥有一个预定义的布局切换键,并将使用它在您的主布局和此布局之间切换。 同样,布局切换键可以配置为Shift (仅保持切换布局)或CapsLock

     // emulate numpad on first 3 columns of alphabetic keys // leave other alphanumeric keys undefined // otherwise from /usr/share/X11/xkb/symbols/us (basic stanza) default partial alphanumeric_keys modifier_keys xkb_symbols "qweasdzxc" { name[Group1]= "Numpad Emulation"; key  { [ 7, division ] }; // q key  { [ 8, multiply ] }; // w key  { [ 9, minus ] }; // e key  { [ 4, F ] }; // a key  { [ 5, E ] }; // s key  { [ 6, D ] }; // d key  { [ 1, C ] }; // z key  { [ 2, B ] }; // x key  { [ 3, A ] }; // c // hexadecimal just for fun, replace if desired }; // end "qweasdzxc" // rules to load this as a layout ! layout = symbols qweasdzxc = qweasdzxc // load from commandline. may need -I/path/to/custom/xkb setxkbmap -layout us,qweasdzxc -option grp:caps_toggle 

可以通过更改/usr/share/X11/xkb/{symbols,rules}系统XKB文件或将自定义项存储在本地XKB配置文件中来实现这两个选项中的任何一个。 对xkeyboard-config软件包的更新可以消除对系统文件的更改,但更容易使用系统布局设置工具,如/etc/default/keyboard或GNOME的设置守护程序。