25

I'm trying to achieve the following mapping
keycode 135 = <Ctrl-C>

Is it possible to achieve this in some way?

Starfish
  • 469
  • 3
  • 14
xralf
  • 16,149
  • 29
  • 101
  • 149
  • Maybe see [my answer on AskUbuntu](http://askubuntu.com/questions/131900/how-do-i-switch-the-command-key-and-control-key-on-a-macbook-pro-12-04). Might also help, though @Gilles answer looks great. – kalaracey Mar 13 '13 at 13:25

3 Answers3

17

That's not possible with xmodmap. I don't think it's possible with XKB either, but I'm not sure.

Is your aim to have a key that's always identical to pressing Ctrl+C (e.g. in a terminal, it would interrupt the running program), or to have a clipboard copy key? If the latter, try

keycode 135 = XF86Copy

The XF86Copy keysym is intended for a copy-to-clipboard key, but I don't know how many applications have that shortcut out-of-the-box.

If you're on Ubuntu, and possibly even if you aren't, the recommended method to set up additional (“multimedia”) keys is keytouch.

If you really want the key to be equivalent to Ctrl+C, your desktop environment or window manager may let you bind the keysym to a command that generates key press and release events for that key combination. If you prefer or must use a DE/WM-agnostic method, you can use xbindkeys to bind an arbitrary shell command to a key, and xmacro to manufacture key events to send to a window. You'll still need to have a keysym associated with the key; a good choice is F13 (or wherever the numbered function keys on your keyboard leave off). Then put this in your ~/.xbindkeysrc:

"{ echo KeySymPress Control_L; echo KeySym C; echo KeySymRelease Control_L; } | xmacroplay"
  F13

You'll need to start xbindkeys with your X session — from your ~/.xinitrc or ~/.xsession if you have one, or from the appropriate configuration interface in your DE/WM.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
  • Thank you. I'd like to achieve that always when I press the key between right alt and right ctrl (keycode 135) it will be the same as Ctrl+C (This is only example, I'd like to use more keys that aren't utilized on my keyboard and assign them shortcuts Ctrl+A, Ctrl+B, Ctrl+C etc., it doesn't matter what is the function (e.g. copy)). Could you achieve it with another program (xbindkeys, xmacro)? – xralf Apr 12 '11 at 18:39
  • You can also try xdotool, it's a bit easier to use than xmacro. – Ben Davis Sep 08 '15 at 22:29
2

Have you tried Autokey ? It is a much easier way than xbindkeys or xmacro.

slm
  • 363,520
  • 117
  • 767
  • 871
user34101
  • 21
  • 1
-1

xmodmap -e 'keycode 133 = Menu

133 in this case is Super (ubuntu logo on touchpad)

fred
  • 1
  • 4
    Hi and welcome to the site. Could you please add some context? Is this a command? A configuration setting? On what operating system? Why would there be an Ubuntu logo on a touchpad? Did you mean keyboard, and even so why would there be an Ubuntu logo there? Could this maybe be specific to _your_ system? In any case, how would this help if the OP wants to map the key to Ctrl+C? – terdon Jun 12 '22 at 16:47
  • 1
    There also seems to be a missing single quote in your command. The user in the question wants to map `Ctrl+C` with key code 135. – Kusalananda Jun 12 '22 at 17:03