How can I map Control_L + Space to Return?

preferably to be done with xmodmap.

I did trying to search for some answers but with no success.

My current solution is: ~/.Xmodmap keycode 65 = space Return space keycode 37 = Control_L Mode_switch Control_L

~/.vimrc: inoremap <C-@> <CR> cnoremap <C-@> <CR> nnoremap <C-@> <CR>

any solutions for change ctrl+space to behave like return( a.k.a The 'Enter' key) for the entire system?

  • That depends on the terminal/emulator used. You could use xterm's translation resource to map control+space to return. Other terminals differ. – Thomas Dickey Oct 23 '15 at 21:00

I did some more research and have tried several different solutions, finally settled with one solutions which doesn't result in any delay or inconsistency. The solution below not only work for terminal but also other applications.

Tools that I used:

xdotool, xbindkeys

(1) install xdotool and xbindkeys:

$ sudo apt-get update
$ sudo apt-get install xdotool
$ sudo apt-get install xbindkeys

(2) create xbindkey config file:

$ xbindkeys -d > ~/.xbindkeysrc

(3) remap Ctrl-Space in xbindkeysrc

"xset r off; xdotool keyup --window 0 space key --clearmodifiers --window 0 KP_Enter; xset r on"
   m:0x14 + c:65
   Control+Mod2 + space

(4) Kill current xbindkeys

I'm not sure why this is necessary but simply source xbindkeysrc doesn't replace current config. Thus, you have to kill xbindkeys

$ killall xbindkeys
$ xbindkeys -f ~/.xbindkeysrc

All set.


map ctrl+~ to be /

"xset r off; xdotool keyup --window 0 grave key --clearmodifiers --window 0 slash; xset r on"
   m:0x14 + c:49
   Control+Mod2 + grave


  • Thanks, that works. Especially the xdotool trick of "keyup" is needed for it to work properly. – Yan King Yin Aug 9 '18 at 3:38

xmodmap will not take you to your goal. The closest in its repertoire is this paragraph (reformatted to show the points):

The list of keysyms is assigned to the indicated keycode (which may be specified in decimal, hex or octal and can be determined by running the xev program). Up to eight keysyms may be attached to a key, however the last four are not used in any major X server implementation.

  • The first keysym is used when no modifier key is pressed in conjunction with this key,
  • the second with Shift,
  • the third when the Mode_switch key is used with this key and
  • the fourth when both the Mode_switch and Shift keys are used.

That is, you could use xmodmap to associate some existing key with the shift-modifier. However, you want that existing key to be controlspace which does not correspond to a key you are likely to find on your keyboard—nor is there an existing keysym for it. Rather, you may use controlspace on occasion to generate an ASCII NUL, but it is so rarely used that there is no standard key on the keyboard for this.

However - both xterm and urxvt can be configured, separately and with different methods to distinguish controlshiftspace. With xterm, that would be the translations resource, while urxvt has a keysym.sym resource.

If you are using xmodmap, likely you are using either xterm or rxvt (perhaps urxvt). With other terminals, people tend to wade into the xkb morass. But reviewing the documentation, it seems to have the same limitation as xmodmap (essentially more of the same thing, no genuinely new capability in this area).

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.