如何在Linux中模拟集成数字小键盘光标键 [英] How to emulate integrated numeric keypad cursor keys in linux

查看:152
本文介绍了如何在Linux中模拟集成数字小键盘光标键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在许多较旧的笔记本电脑和某些紧凑型键盘上,有一个集成数字键盘主键盘区域.此备用键盘是通过左侧Ctrl键旁边的特殊"Fn"键激活的.

On many older laptops and some compact keyboards there is an integrated numeric keypad in the main keyboard area. This alternate keypad is activated with a special 'Fn' key next to the left Ctrl key.

作为一名程序员,我学会了使用光标移动键(箭头,PgUp,PgDn等),发现它极大地提高了我的编程速度.而且,好处并不仅仅局限于单个应用程序,而专用快捷键就是这种情况.

As a programmer I learned to use the cursor movement keys (arrows, PgUp, PgDn etc.) and found it greatly improved my programming speed. And the benefits were not bound to just a single application as is the case with specialised shortcut keys.

在常规PC键盘上,可以使用"Windows键"来模拟"Fn"键和相应的集成数字小键盘.当我以前使用MS Windows时,我发现 Autohotkey 能够使用

On conventional PC keyboards, the 'Windows Key' can be used to emulate the 'Fn' key and a corresponding integrated numeric keypad. When I used to use MS Windows I found Autohotkey was able to map the keys using a simple script.

最近,我了解了xkb及其如何用于

Recently I learned about xkb and how it can be used to map keystrokes at a very low level.

什么是xkb键盘映射配置文件,它将使用Windows键作为fn键来模拟集成数字小键盘?

提示(?):我怀疑文件的外观很像Debian衍生版Linux发行版中的'/usr/share/X11/xkb/symbols/keypad '文件.此键盘"文件包含在"/usr/share/X11/xkb/symbols/pc "文件的顶部.

Hint(?): I suspect the file will look a lot like the '/usr/share/X11/xkb/symbols/keypad' file on a Debian-derivative linux distro. This 'keypad' file is included at the top of the '/usr/share/X11/xkb/symbols/pc' file.

相应的自动热键脚本供参考(# == WinKey):

The corresponding autohotkey script for reference (# == WinKey):

#8::Up
#k::Down
#u::Left
#o::Right

#7::Home
#j::End
#9::PgUp
#l::PgDn

#m::Insert
#.::Delete

;(Scroll with the left-over keys)
#i::WheelUp
#,::WheelDown

请注意,所有这些键都需要与 Ctrl,Alt,Shift 以及Windows键的任意组合一起使用.

Note that all these keys need to work with any combination of Ctrl, Alt, Shift as well as the Windows Key.

推荐答案

在Linux/XKB中的主键盘上安装类似数字小键盘的光标键的步骤...

Steps to install numeric keypad-like cursor keys on the main keyboard in Linux / XKB...

  1. xkbcomp $ DISPLAY original.xkb (以防万一;)
  2. xkbcomp $ DISPLAY custom.xkb
  3. 编辑custom.xkb
  4. 在本节末尾添加以下内容:xkb_types"..." {

  1. xkbcomp $DISPLAY original.xkb (just in case ;)
  2. xkbcomp $DISPLAY custom.xkb
  3. Edit custom.xkb
  4. Add the following at the end of section: xkb_types "..." {

type "WinKeyAsFnKey" {
  modifiers = Shift+Super;
  map[Shift] = level2;
  map[Super] = level3;
  map[Super+Shift] = level3;
  level_name[Level1] = "Base";
  level_name[Level2] = "Caps";
  level_name[Level3] = "Fn";
};

  • 在xkb_symbols"..." {

  • Add the following at the end of section xkb_symbols "..." {

     key <AE07> {type="WinKeyAsFnKey",symbols[Group1]=[7,ampersand,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<HOME>,clearmods=Super)]};
     key <AE08> {type="WinKeyAsFnKey",symbols[Group1]=[8,asterisk,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<UP>,clearmods=Super)]};
     key <AE09> {type="WinKeyAsFnKey",symbols[Group1]=[9,parenleft,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<PGUP>,clearmods=Super)]};
     key <AD07> {type="WinKeyAsFnKey",symbols[Group1]=[u,U,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<LEFT>,clearmods=Super)]};
     key <AD09> {type="WinKeyAsFnKey",symbols[Group1]=[o,O,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<RGHT>,clearmods=Super)]};
     key <AC07> {type="WinKeyAsFnKey",symbols[Group1]=[j,J,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<END>,clearmods=Super)]};
     key <AC08> {type="WinKeyAsFnKey",symbols[Group1]=[k,K,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<DOWN>,clearmods=Super)]};
     key <AC09> {type="WinKeyAsFnKey",symbols[Group1]=[l,L,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<PGDN>,clearmods=Super)]};
     key <AB07> {type="WinKeyAsFnKey",symbols[Group1]=[m,M,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<INS>,clearmods=Super)]};
     key <AB09> {type="WinKeyAsFnKey",symbols[Group1]=[period,greater,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<DELE>,clearmods=Super)]};
    

  • 保存custom.xkb

  • Save custom.xkb

    我仍在使用'i'和','进行鼠标滚动.

    I'm still working on the mouse scroll with 'i' and ','.

    编辑: 上面的解决方案在Google Chrome和基于Chrome的应用程序(如Slack)上不能很好地发挥作用.

    EDIT: The above solution does not play nice with Google Chrome and Chrome-based apps (like Slack).

    替代方法是使用可编程键盘.我使用 CoolerMaster万能S键盘的售后PCB . Easy AVR 布局是

    Alternative approach is to use a programmable keyboard. I use an after-market PCB for a CoolerMaster Masterkeys S keyboard. The Easy AVR layout is available online (although currently the left win-key now doesn't work by itself...I use the right one).

    这篇关于如何在Linux中模拟集成数字小键盘光标键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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