ubuntu 按键remap

今天同事键盘的一个按键不好使,琢磨了下ubuntu的按键remap,还是挺方便的,把找到的相关资料记录下来方便以后查阅.

有个博客还真不错,有啥需要记忆的都丢上来,以后自己看也方便,呜呜委屈,早怎么没想到呢


For remapping certain keys you need two tools. First xev (command-line tool) and second xmodmap(also command-line tool). Both should be available in Ubuntu without extra installing them.

  1. Start terminal window and run xev. Now it's active and waits for you to press a key. Then press the key whose behaviour you want to change. i.e. PgUp.

  2. xev will output some information about the pressed key. The third line is important. It should look similar to:

    state 0x10, keycode 110 (keysym 0xff55, Prior), same_screen YES,
    

    in this example Prior is the name of the behaviour the key is assigned to at the moment, the number keycode is the internal id to recognize the key. Now do this with another key i.e. PgDown give this output

    state 0x10, keycode 115 (keysym 0xff56, Next), same_screen YES,
    

    Here again the interesting part for us is keycode 115 and Next - the name of the behaviour.

  3. now when you want to swap the two keys use xmodmap.

     xmodmap -e "keycode 110 = Next"
    

    This changes the key with keycode 110 on your keyboard to the action Next. It's pretty simple.

    Note that if the key you are mapping should have a different meaning when used with the Shiftkey (for example for British keyboard layouts, Shift+2 gives quotation marks) then you can simply list the secondary command after the first. For example if you want the key with code 53 to map to backslash normally, but to the bar symbol when used with shift, you might do:

     xmodmap -e "keycode 53 = backslash bar"
    

Additional information: The sequence of these mappings is KeyShift+Keymode_switch+Keymode_switch+Shift+KeyAltGr+KeyAltGr+Shift+Key. To skip a column use NoSymbol. Moreover,here is a comprehensive list of all keysyms.

Note: These change are for the active X session only and will be lost after reboot. When you want to save the changes permanently you have to run the following commands after the ones above:

xmodmap -pke >~/.Xmodmap

(it creates a file named .Xmodmap in your home directory (~))

Then you have to create a file named .xinitrc in your home directory where you put command xmodmap .Xmodmap in.

You can now modify .Xmodmap and run xmodmap .Xmodmap from console to see the changes immediately. The changes in .Xmodmap will persist.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值