logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

xcape - use a modifier key as another key

Author

xcape was written by Albin Olsson (albin dot olsson at gmail dot com)

John Hill                                          2014-02-13                                           XCAPE(1)

Description

xcape  allows  a  modifier  key to be used as another key when it is pressed and released on its own. The
       default behaviour is to generate the Escape key in place of Control_L (Left Control).

Examples

       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:
              xcape-e 'Shift_L=Escape;Control_L=Control_L|O'

       In  conjugation  with  xmodmap it is possible to make an ordinary key act as an extra modifier. First map
       the key to the modifier with xmodmap and then the modifier back to the key with xcape. As an example,  we
       can make the space bar work as an additional ctrl key when held with the following sequence of commands:

       First, map an unused modifier's keysym to the spacebar's keycode and make it a control modifier. It needs
       to be an existing key so that emacs won't spazz out when you press it. Hyper_L is a good candidate.

              spare_modifier="Hyper_L"
              xmodmap-e "keycode65 = $spare_modifier"
              xmodmap-e "removemod4 = $spare_modifier"
              # hyper_l is mod4 by default
              xmodmap-e "addControl = $spare_modifier"

       Next, map space to an unused keycode (to keep it around for xcape to use).

              xmodmap -e "keycodeany = space"

       Finally use xcape to cause the space bar to generate a space when tapped.

              xcape-e "$spare_modifier=space"

Expression Syntax

       Expression  syntax  is  ´ModKey=Key[|OtherKey]´.   Multiple expressions can be passed, delimited by semi-
       colons (;).

       A list of keysyms can be found in the header file <X11/keysymdef.h> (without the XK_ prefix).

       Note that shifted keys must be specified as a shift key followed by the key to be pressed rather than the
       actual name of the character. For example to generate  "{"  the  expression  ´ModKey=Shift_L|bracketleft´
       could be used (assuming that you have a key with ´{´ above ´[´).

       You  can  also  specify  ModKey  in  decimal  (prefix  #),  octal  (#0), or hexadecimal (#0x). It will be
       interpreted as a keycode unless no corresponding key name is found.

Name

       xcape - use a modifier key as another key

Options

-d     Debug mode.  Will run as a foreground process.

       -ttimeout
              Give a timeout in milliseconds.  If you hold a key longer than timeout a key  event  will  not  be
              generated.

       -emap-expression
              Use map-expression as the expression(s).

See Also

xmodmap(1), xev(1)

Synopsis

xcape [-d] [-ttimeout] [-emap-expression]

See Also