Multiple keycodes from one keypress. Creating eg. single-key copy/paste commands

Peter Hutterer mailinglists at
Tue Apr 10 16:29:41 PDT 2007

On 06/04/2007, at 09:24 , nitram at wrote:
> I would like to assign a single key for copy and another for paste.
> Since most applications accept CTRL-C, and CTRL-V for these actions, I
> would like to be able to assign eg. F11, F12 respectively for these
> actions.
> I have fooled around for some time with, xmodmap, xkeycaps, but it  
> seems
> that I can't make it work. Have a feeling xmodmap does not support  
> this
> kind of binding ?
> Would I need to hack into the X keyboard driver ? If so, then I  
> will do
> that. Just need to know which files to modify code in.

The driver calls xf86PostKeyboardEvent() with the keycode. This goes  
to GetKeyboardEvents() and is then processed in the unknown abyss of  
XKB. Eventually X spits out the right events to the client. I guess  
the easiest way if you want to hack the driver is to make it call  
xf86PostKeyboardEvent() twice, once with the ctrl keycode, once with  
the C keycode.
Look at PostKbdEvent in xf86-input-keyboard/src/kbd.c

Of course, this seems quite stupid to do as you would be out of sync  
with the released drivers but I don't know if you can just simply map  

>  I have also tried making this happen by modifying the blackbox  
> keyboard
> grabber (bbkeys) but it seems that when I grab eg. the F11 key and  
> try to
> send new key-events to the active window, there will also be generated
> some focus in/out, notify events, which for some reason makes at  
> least the
> CTRL-C event not to reach the active window correctly. CTRL-V I can  
> make
> work although it also generates all the focus in/out notify events,  
> which
> seems to be a side effect of bbkeys grabbing keys.

AFAIK the focus in/out are generated when the passive grab is  
deactivated. See man XGrabKeyboard for an explanation.


Multi-Pointer X Server

More information about the xorg mailing list