Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

键盘按键映射修改 #29

Open
itgoyo opened this issue Dec 25, 2017 · 1 comment
Open

键盘按键映射修改 #29

itgoyo opened this issue Dec 25, 2017 · 1 comment

Comments

@itgoyo
Copy link
Owner

itgoyo commented Dec 25, 2017

键盘映射修改

  • Window

使用软件AutoHotkey来修改或者开源软件sharpkeys

或者使用MapKeyboard来修改(个人推荐)

2020-12-20修改
现在推荐使用PowerToys,支持组合按键映射

  • Mac

使用软件Karabiner来修改

  • Linux

使用shell脚本来修改

例如常见的Esc和CapsLock互换


#!/usr/bin/env bash
#
# different DM uses different filename:
# lightdm: ~/.xprofile
# slim:    ~/.xinitrc

# from old ~/.xinitrc
if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi

log () {
  echo "$1=<$2>" >> ~/.xinitrc_LOG
}

init_____xfce () {
  export XIM=fcitx
  export GTK_IM_MODULE=xim
  export QT_IM_MODULE=xim
  export XMODIFIERS=@im=fcitx

  local hostname="$(hostname)"
  if [ "$hostname" = "cosmos" ]; then
    xrandr --output HDMI-0 --set underscan on
  fi

  if [ "$hostname" = "djpon" ] || [ "$hostname" = "cosmos" ] ;then
    setxkbmap jp
  else
    log "not running setxkbmap jp"
  fi

  if [ "$hostname" = "thinkpad" ];then
    synclient TouchPadOff=1 # disable touchpad
  fi

  # fcitx-xkb causes xmodmap settings to be reset
  fcitx -rd --disable fcitx-xkb

  xmodmap -e 'clear Lock'
  xmodmap -e 'keycode 66 = Escape'
  xmodmap -e 'keycode 9 = Caps_Lock'
  log "xmodmap executed" "$(date)"
  xset r rate 200 32

  # disable pc speaker
  xset -b

  # ssh-agent
  # eval $(ssh-agent -s)
}

if [[ -d "$HOME/Android/Sdk" ]]; then
  export ANDROID_HOME="$HOME/Android/Sdk"
fi

init_____xfce
log 'xinitrc' 'running'
unset init_____xfce
unset log

http://blog.csdn.net/lslin405/article/details/68059331

最近确定在网上再找找办法解决,最后找到了这个方法dconf-editor,使用这个修改切换中英文都不会发生改变,修改是永久的,为了下次修改方便,特地在此记录下,如果对他人有所帮助那再好不过了。按照提示直接sudo apt install dconf-editor进行安装,接着运行dconf-editor命令启动图形界面,选择org >> gnome >> desktop >> input-sources,修改xkb-options为['caps:swapescape'],如下图:


xmodmap -pke | grep -i tab
xmodmap -pke | grep -i grave
上面两条命令分别找到 tab 和 ~ 两个键对应的keycode,比如,在我的系统上是:
keycode 23 = Tab ISO_Left_Tab Tab ISO_Left_Tab
和
keycode 49 = grave asciitilde grave asciitilde
你的系统上对应的keycode可能略有不同。 如果你的xmodmap没有Tab的定义,也没关系,用xev也能找到keycode,然后创建一个 ~/.Xmodmaprc 文件,内容为
keycode 49 = Tab ISO_Left_Tab Tab ISO_Left_Tab
keycode 23 = grave asciitilde grave asciitilde
就是把标准的结果互换一下,然后保存 ~/.Xmodmaprc
在命令行下 xmodmap ~/.Xmodmaprc,就行了
注意,我这里tab对应keycode 23, ~对应49,你的不一定是这样的,可以用xev来识别。

此方法只是临时的

Linux Mint

  • click System Settings
  • keyboard layout
  • options...(lower right hand corner)
  • caps lock key behaviour (4th down)
  • Scroll down and choose "Swap ESC and Caps Lock".
@itgoyo
Copy link
Owner Author

itgoyo commented Nov 10, 2018

或者直接使用命令

setxkbmap -option caps:swapescape

也不知道是不是永久的,Linux mint亲测有效。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant