I tried several things:

setxkbmap -option caps: return
setxkbmap -option caps: enter

I also tried to modify the file /usr/share/X11/xkb/symbols/pc by:

"Key <CAPS> {[Enter]};"

But nothing worked.

3 Answers 3


Not sure if it helps (as not purely in setxkbmap), but:

setxkbmap -option caps:none
xmodmap -e "keycode 66 = Linefeed"

Change back:

setxkbmap -option
xmodmap -e "keycode 66 = Caps_Lock"

You can check with something like:

xev | sed -ne '/^KeyPress/,/^$/p'

to get keycodes.

  • 1
    While this works to insert a line break, this doesn't act a s return key. Use xmodmap -e "keycode 66 = Return" to emulate a return key.
    – bkzland
    Mar 2, 2015 at 10:12
  • This answer was perfect for what I wanted to do. I wanted to rebind capslock to a key I wasn't using for anything (F1). Now I can use capslock as my tmux prefix.
    – byxor
    Jul 26, 2017 at 10:07

I also tried to modify the file /usr/share/X11/xkb/symbols/pc by:

"Key <CAPS> {[Enter]};"

But nothing worked.

Almost there... There is no such thing as Enter. The keyword here is Return so edit your /usr/share/X11/xkb/symbols/pc like this (original line commented out with //):

// key <CAPS> {     [ Caps_Lock             ]       };
key <CAPS> {        [ Return                ]       };

and then your CapsLock should act as Return.


For Gnome (and Ubuntu 18.04), you can use Gnome Tweak tool, and change it under Keyboard and Mouse settings. Click 'Additional Layout Options', and you will find settings for Caps Lock.

Change Ubuntu 18.04/Gnome Caps Lock behaviour

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.