Skip to content
cajhin edited this page Mar 19, 2024 · 3 revisions

REWIRE keyword

REWIRE maps keys to other keys or virtual keys.

Use this for hard, unconditional rules.

Changing modifiers is usually a job for REWIRE.

Simple Syntax

REWIRE inKey outKey

inKey, outKey : keylabel of any real key

Windows knows nothing about the original, incoming inKey; only the outKey is sent to Windows.

Examples

REWIRE A B
A down results in B down
A up results in B up
Shift+A results in Shift+B

REWIRE Caps LCtrl
CapsLock down results in Left Control down
CapsLock up results in Left Control up
Shift+CapsLock results in Shift+Control

Syntax with Virtual Keys and/or Tapping

REWIRE inKey outKey (ifTappedOutKey OR //) (ifTapAndHoldOutKey)

inKey : keylabel of any real key that you can press

outKey : any real key, or a capsicain virtual key like MOD9

ifTappedOutKey : sent out when the inKey is tapped; or no special action if it is //.
This will send both the 'down' and 'up' event for the ifTappedOutKey, so it makes sense only for character keys, not for modifiers.

Note that REWIRE is for changing keys. The regular "a modifier was tapped" state is independent of this.

ifTapAndHoldOutKey : used instead of outKey if inKey is tapped, then pressed.
Note: Tap&Hold always triggers a tap event first. Set ifTappedOutKey to // when you define ifTapAndHoldOutKey (otherwise you would get strange undefined double action on both 'tapped' and 'tap&hold').

Examples

REWIRE Caps MOD9
Real CapsLock key results in virtual modifier MOD9

REWIRE TAB MOD11 TAB
Press TAB -> MOD11 down
Tap TAB (press and release without any other key in between) -> TAB down, TAB up

REWIRE LALT MOD12 // LALT

Press LALT -> MOD12 down

Tap LALT -> // no action; taps simply result in MOD12 down, MOD12 up and "MOD12-was-tapped state" which could alter the following key via a 'tapped' combo. Example: tap LALT, then U for 'cursor up': COMBO U [T... .... ....] > key(UP)

Tap-once-then-hold-down LALT -> LALT

Complications

All REWIREs are processed before COMBOs and ALPHAMAPs

With this config, both Ctrl-A and Ctrl-B will trigger COMBO B:

COMBO A [&.] > ...
COMBO B [&.] > ...
REWIRE A B

If you want to change character keys, but not the combos with those keys, it is probably a better idea to map with ALHPA maps instead.

REWIRE does not wait to check for taps

If you tap a key, it triggers the optional "if tapped" key.

The initial key down has already triggered the "to key".

If you tap A with this config, it will result in "B down, B up, C down, C up" :

REWIRE A B C

Note that the 'outKey' is NOT optional, you cannot put // here.
(you can map to key 'NOP' NoOPeration though, which is processed, but should not have any effect).

The same logic applies with "Tap and Hold". This will always trigger both the "to" key and the "if tapped" key, unless the "if tapped" key is "//" (then the tap is ignored).

Tapping should therefore only be used with keys that are rewired to virtual modifiers, like CapsLock to MOD9 or LCtrl if tap-hold:

REWIRE CAPS MOD9 // LCTRL

When a key is rewired to Shift (REWIRE CAPS LSHF // LCTRL) , Tappings will forward Shift events to Windows, which can have unintended side effects.