Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Linux utility to make control key send escape key events when pressed on its own.
C
branch: master

This branch is 2 commits ahead, 31 commits behind alols:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
LICENSE
Makefile
README.md
xcape.c

README.md

XCAPE

xcape allows you to use a modifier key as another key when pressed and released on its own. Note that it is slightly slower than pressing the original key, because the pressed event does not occur until the key is released. The default behaviour is to generate the Escape key when Left Control is pressed and released on its own. (If you don't understand why anybody would want this, I'm guessing that Vim is not your favourite text editor ;)

Minimal building instructions

$ sudo apt-get install git gcc make libx11-dev libxtst-dev pkg-config
$ mkdir xcape
$ cd xcape
$ git clone https://github.com/alols/xcape.git .
$ make

Usage

$ xcape [-d] [-t <timeout ms>] [-e <map-expression>]

-d

Debug mode. Does not fork into the background.

-t <timeout ms>

If you hold a key longer than this timeout, xcape will not generate a key event. Default is 50 ms.

-e <map-expression>

The expression has the grammar 'ModKey=Key[|OtherKey][;NextExpression]'

The list of key names is found in the header file X11/keysymdef.h (remove the XK_ prefix).

Example

xcape -e 'Shift_L=Escape;Control_L=Control_L|O'

This will make Left Shift generate Escape when pressed and released on it's own, and Left Control generate Ctrl-O combination when pressed and released on it's own.

Note regarding xmodmap

If you are in the habit of remapping keycodes to keysyms (eg, using xmodmap), there are two issues you may encounter.

1) You will need to restart xcape after every time you modify the mapping from keycodes to keysyms (eg, with xmodmap), or xcape will still use the old mapping.

2) The key you wish to send must have a defined keycode. So for example, with the default mapping Control_L=Escape, you still need an escape key defined in your xmodmap mapping. (I get around this by using 255, which my keyboard cannot send).

Contact

Find the latest version at https://github.com/alols/xcape

The author can be reached at albin dot olsson at gmail dot com

Something went wrong with that request. Please try again.