按shift+number的反转作用

Nah*_*siN 9 keyboard keyboard-layout shortcut-keys

有什么办法可以反转键盘动作Shift+[1..9]的作用吗?基本上我发现自己在数字上使用符号的频率比数字本身要高得多。我有数字的小键盘。很多这些符号用于编码和乳胶。因此,如果有人知道我如何在不使用 shift 的情况下获得 !@#$%^&*() ,我将不胜感激。

rev*_*dj1 7

这实际上很容易使用 xmodmap 实现。只需创建一个新文件,内容如下:

keycode  10 = exclam 1 exclam 1
keycode  11 = at 2 at 2
keycode  12 = numbersign 3 numbersign 3
keycode  13 = dollar 4 dollar 4
keycode  14 = percent 5 percent 5
keycode  15 = asciicircum 6 asciicircum 6
keycode  16 = ampersand 7 ampersand 7
keycode  17 = asterisk 8 asterisk 8
keycode  18 = parenleft 9 parenleft 9
keycode  19 = parenright 0 parenright 0
Run Code Online (Sandbox Code Playgroud)

将其作为 .Xmodmap 保存在您的主目录的根目录中(大写很重要)。现在,只需注销并重新登录(您可能需要重新启动),您的密钥将被交换。继续阅读我是如何想出这个的。我用来解决这个问题的信息来自这里。启动终端并输入以下命令:

xmodmap -pke
Run Code Online (Sandbox Code Playgroud)

这将吐出一堆键码设置/值对,如下所示:

......
keycode  27 = r R r R
keycode  28 = t T t T
keycode  29 = y Y y Y
keycode  30 = u U u U
keycode  31 = i I i I
keycode  32 = o O o O
keycode  33 = p P p P
keycode  34 = bracketleft braceleft bracketleft braceleft
keycode  35 = bracketright braceright bracketright braceright
keycode  36 = Return NoSymbol Return
keycode  37 = Control_L NoSymbol Control_L
keycode  38 = a A a A
keycode  39 = s S s S
keycode  40 = d D d D
keycode  41 = f F f F
keycode  42 = g G g G
keycode  43 = h H h H
keycode  44 = j J j J
keycode  45 = k K k K
......
Run Code Online (Sandbox Code Playgroud)

键码是物理键盘上的键,等号右侧的值是发送到 PC 的值。有四个的原因是第一个是普通的,第二个是按下了 shift,并且一旦您单击 Scroll Lock 按钮,似乎启用了第三个(普通)和前进(shift)。如您所见,这为您提供了很大的灵活性,可以做任何您想修改键盘的事情。

现在,这仅在您登录 X(如在 GUI 中)时才有效,因此得名。如果您在 Gnome、Unity 等中启动终端,您仍然可以很好地使用 Xmodmap,但是如果您希望在控制台中使用相同的功能(即在按下 CTRL+ALT+1 后,进入一个盒子,在服务器上工作,或没有 GUI 的 PC)您将需要使用加载键。尽管总体思路相同,但 loadkeys 提供了更多的功能和粒度,因此稍微复杂一些。现在,这些命令都必须从实际的控制台完成,它们不能用终端模拟器完成,否则你会收到一个错误,像这样:Couldn't get a file descriptor referring to the console

首先,我们需要创建我们的默认键盘映射,如下所示:

dumpkeys > ~/my_keymap.map
Run Code Online (Sandbox Code Playgroud)

如果你真的搞砸了,最好复制一份。现在,我们只需要编辑它,并进行更改。每个键定义如下所示:

keycode   2 = one              exclam           one              one             
    alt keycode   2 = Meta_one        
    shift   alt keycode   2 = Meta_exclam     
    altgr   alt keycode   2 = Meta_one        
    shift   altgr   alt keycode   2 = Meta_one        
    shiftl  keycode   2 = one             
    shift   shiftl  keycode   2 = exclam          
    altgr   shiftl  keycode   2 = one             
    shift   altgr   shiftl  keycode   2 = one             
    alt shiftl  keycode   2 = Meta_one        
    shift   alt shiftl  keycode   2 = Meta_exclam     
    altgr   alt shiftl  keycode   2 = Meta_one        
    shift   altgr   alt shiftl  keycode   2 = Meta_one        
    shiftr  keycode   2 = one             
    shift   shiftr  keycode   2 = exclam          
    altgr   shiftr  keycode   2 = one             
    shift   altgr   shiftr  keycode   2 = one             
    alt shiftr  keycode   2 = Meta_one        
    shift   alt shiftr  keycode   2 = Meta_exclam     
    altgr   alt shiftr  keycode   2 = Meta_one        
    shift   altgr   alt shiftr  keycode   2 = Meta_one        
    shiftl  shiftr  keycode   2 = one             
    shift   shiftl  shiftr  keycode   2 = exclam          
    altgr   shiftl  shiftr  keycode   2 = one             
    shift   altgr   shiftl  shiftr  keycode   2 = one             
    alt shiftl  shiftr  keycode   2 = Meta_one        
    shift   alt shiftl  shiftr  keycode   2 = Meta_exclam     
    altgr   alt shiftl  shiftr  keycode   2 = Meta_one        
    shift   altgr   alt shiftl  shiftr  keycode   2 = Meta_one        
    ctrll   keycode   2 = one             
    shift   ctrll   keycode   2 = exclam          
    altgr   ctrll   keycode   2 = one             
    shift   altgr   ctrll   keycode   2 = one             
    alt ctrll   keycode   2 = Meta_one        
    shift   alt ctrll   keycode   2 = Meta_exclam     
    altgr   alt ctrll   keycode   2 = Meta_one        
    shift   altgr   alt ctrll   keycode   2 = Meta_one        
    shiftl  ctrll   keycode   2 = one             
    shift   shiftl  ctrll   keycode   2 = exclam          
    altgr   shiftl  ctrll   keycode   2 = one             
    shift   altgr   shiftl  ctrll   keycode   2 = one             
    alt shiftl  ctrll   keycode   2 = Meta_one        
    shift   alt shiftl  ctrll   keycode   2 = Meta_exclam     
    altgr   alt shiftl  ctrll   keycode   2 = Meta_one        
    shift   altgr   alt shiftl  ctrll   keycode   2 = Meta_one        
    shiftr  ctrll   keycode   2 = one             
    shift   shiftr  ctrll   keycode   2 = exclam          
    altgr   shiftr  ctrll   keycode   2 = one             
    shift   altgr   shiftr  ctrll   keycode   2 = one             
    alt shiftr  ctrll   keycode   2 = Meta_one        
    shift   alt shiftr  ctrll   keycode   2 = Meta_exclam     
    altgr   alt shiftr  ctrll   keycode   2 = Meta_one        
    shift   altgr   alt shiftr  ctrll   keycode   2 = Meta_one        
    shiftl  shiftr  ctrll   keycode   2 = one             
    shift   shiftl  shiftr  ctrll   keycode   2 = exclam          
    altgr   shiftl  shiftr  ctrll   keycode   2 = one             
    shift   altgr   shiftl  shiftr  ctrll   keycode   2 = one             
    alt shiftl  shiftr  ctrll   keycode   2 = Meta_one        
    shift   alt shiftl  shiftr  ctrll   keycode   2 = Meta_exclam     
    altgr   alt shiftl  shiftr  ctrll   keycode   2 = Meta_one        
    shift   altgr   alt shiftl  shiftr  ctrll   keycode   2 = Meta_one 
Run Code Online (Sandbox Code Playgroud)

如您所见,它提供了更多的功能/粒度。对于每个键,只需交换移位和常规值,即这里将是交换的一个键:

keycode   2 = exclam              one           exclam              exclam             
    alt keycode   2 = Meta_exclam        
    shift   alt keycode   2 = Meta_one     
    altgr   alt keycode   2 = Meta_exclam        
    shift   altgr   alt keycode   2 = Meta_exclam        
    shiftl  keycode   2 = exclam             
    shift   shiftl  keycode   2 = one          
    altgr   shiftl  keycode   2 = exclam             
    shift   altgr   shiftl  keycode   2 = exclam             
    alt shiftl  keycode   2 = Meta_exclam        
    shift   alt shiftl  keycode   2 = Meta_one     
    altgr   alt shiftl  keycode   2 = Meta_exclam        
    shift   altgr   alt shiftl  keycode   2 = Meta_exclam        
    shiftr  keycode   2 = exclam             
    shift   shiftr  keycode   2 = one          
    altgr   shiftr  keycode   2 = exclam             
    shift   altgr   shiftr  keycode   2 = exclam             
    alt shiftr  keycode   2 = Meta_exclam        
    shift   alt shiftr  keycode   2 = Meta_one     
    altgr   alt shiftr  keycode   2 = Meta_exclam        
    shift   altgr   alt shiftr  keycode   2 = Meta_exclam        
    shiftl  shiftr  keycode   2 = exclam             
    shift   shiftl  shiftr  keycode   2 = one          
    altgr   shiftl  shiftr  keycode   2 = exclam             
    shift   altgr   shiftl  shiftr  keycode   2 = exclam             
    alt shiftl  shiftr  keycode   2 = Meta_exclam        
    shift   alt shiftl  shiftr  keycode   2 = Meta_one     
    altgr   alt shiftl  shiftr  keycode   2 = Meta_exclam        
    shift   altgr   alt shiftl  shiftr  keycode   2 = Meta_exclam        
    ctrll   keycode   2 = exclam             
    shift   ctrll   keycode   2 = one          
    altgr   ctrll   keycode   2 = exclam             
    shift   altgr   ctrll   keycode   2 = exclam             
    alt ctrll   keycode   2 = Meta_exclam        
    shift   alt ctrll   keycode   2 = Meta_one     
    altgr   alt ctrll   keycode   2 = Meta_exclam        
    shift   altgr   alt ctrll   keycode   2 = Meta_exclam        
    shiftl  ctrll   keycode   2 = exclam             
    shift   shiftl  ctrll   keycode   2 = one          
    altgr   shiftl  ctrll   keycode   2 = exclam             
    shift   altgr   shiftl  ctrll   keycode   2 = exclam             
    alt shiftl  ctrll   keycode   2 = Meta_exclam        
    shift   alt shiftl  ctrll   keycode   2 = Meta_exclam     
    altgr   alt shiftl  ctrll   keycode   2 = Meta_exclam        
    shift   altgr   alt shiftl  ctrll   keycode   2 = Meta_exclam        
    shiftr  ctrll   keycode   2 = exclam             
    shift   shiftr  ctrll   keycode   2 = one          
    altgr   shiftr  ctrll   keycode   2 = exclam             
    shift   altgr   shiftr  ctrll   keycode   2 = exclam             
    alt shiftr  ctrll   keycode   2 = Meta_exclam        
    shift   alt shiftr  ctrll   keycode   2 = Meta_one     
    altgr   alt shiftr  ctrll   keycode   2 = Meta_exclam        
    shift   altgr   alt shiftr  ctrll   keycode   2 = Meta_exclam        
    shiftl  shiftr  ctrll   keycode   2 = exclam             
    shift   shiftl  shiftr  ctrll   keycode   2 = one          
    altgr   shiftl  shiftr  ctrll   keycode   2 = exclam             
    shift   altgr   shiftl  shiftr  ctrll   keycode   2 = exclam             
    alt shiftl  shiftr  ctrll   keycode   2 = Meta_exclam        
    shift   alt shiftl  shiftr  ctrll   keycode   2 = Meta_one     
    altgr   alt shiftl  shiftr  ctrll   keycode   2 = Meta_exclam        
    shift   altgr   alt shiftl  shiftr  ctrll   keycode   2 = Meta_exclam
Run Code Online (Sandbox Code Playgroud)

额外粒度的原因是因为在使用控制台时,由于其性质,您倾向于使用更多的键盘快捷键。

现在,要测试您的更改,您可以使用以下命令:

loadkeys ~/my_keymap.map
Run Code Online (Sandbox Code Playgroud)

玩玩,使用一些您经常使用的程序,并确保它以您想要的方式工作。如果你搞砸了,你可以使用loadkeys命令回退到默认值。要使其永久化,您可以将命令添加到~/.bashrc文件末尾。