Linux: Make CapsLock Do Home Key

By Xah Lee. Date: . Last updated: .

How to make CapsLock do Home Key on Linux?

Create a file at ~/.Xmodmap with the following content:

! -*- coding: utf-8 -*-
! 2017-02-08
! Linux: Make CapsLock Do Home Key
! http://xahlee.info/linux/linux_capslock_do_home_key.html

! keycode  66 = Caps_Lock NoSymbol Caps_Lock
! keycode 110 = Home NoSymbol Home

clear Lock
keycode 66 = Home NoSymbol Home

Now, run this line in terminal:

xmodmap ~/.Xmodmap

When you restart, that file will run automatically.

Note, xmodmap only works for X11 apps. If you are in linux virtual console [see Linux: How to use Virtual Console] , it won't work.

Here's how to change the key for console.

Change Key for Virtual Console

Written by 11fdriver, on 2018-12-18

Xmodmap does not work when Emacs is used in the console (accessed with Ctrl+Alt+F1 to Ctrl+Alt+F6 ) rather than X11. It's still reasonably simple to change.

Enter the keymap directory (see bottom of `man loadkeys'), and make a copy of your preferred keyboard layout. I use the Dvorak keyboard layout on Void Linux, so my commands are:

$ cd /usr/share/kbd/keymap/i386/dvorak/
# cp dvorak.map.gz xah-fly.map.gz
# Emacs xah-fly.map.gz

Note: Debian and derivatives users may need to install the console-data package:

# apt-get install console-data
$ cd /usr/share/keymaps/i386/dvorak/
# cp dvorak.kmap.gz xah-fly.kmap.gz
# Emacs xah-fly.kmap.gz

The Caps_Lock key is usually bound to keycode 58, and Home to 102, but you should check these yourself using the `showkey' command.

Keymaps often already contain a Caps_Lock binding; just find replace Caps_Lock with Home . The Home key generally needs an extra line to change it to Caps_Lock:

keycode 102 = Caps_Lock !Note: End this file with a blank line.

Test out your new keymap with the `loadkeys' command:

# loadkeys xah-fly.map.gz

On most Linux distributions, load this keymap at boot by editing the relevant line in /etc/rc.conf to read:

KEYMAP=xah-fly

Debian-based distributions instead require you to add this line to /etc/default/keyboard:

KMAP=/usr/share/keymaps/i386/dvorak/xah-fly.kmap.gz

back to Linux: xmodmap Tutorial

Linux Keybinding How-to

  1. Keyboard Software Guide
  2. Swap Control Alt Keys
  3. Set F2 F3 F4 to Cut Copy Paste
  4. CapsLock → Escape
  5. CapsLock → Home
  6. Shift Lock
  7. Key to Switch App
  8. Key Repeat Rate
  9. System Keyboard Layout
  10. Switch Keyboard Layout
  11. Change Volume
  12. xmodmap
  13. xbindkeys
  14. xvkbd
  15. Find Keyboard Key Scancode
  16. X11 Keyboard Key Names
  17. 2 Layouts for 2 Keyboards
  18. Chinese Input Setup

Mouse

  1. Mouse Hover to Auto-Raise Window
  2. Mouse Hover-Click
  3. Set Mouse Single-Click to Open File
  4. How to Set Mouse Speed
  5. How to Swap Mouse Buttons
  6. Set Trackball/Mouse Do Scroll
  7. Setup Accelerated Scroll and AutoScroll
  8. X11 Mouse Button Numbering

If you have a question, put $5 at patreon and message me.