How remap the CapsLock key to work as if it was a Return key using setxkbmap

keyboard shortcutskeyboard-layoutx11xkb

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.

Best Answer

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.