Skip to content

Function: deadkey()

cajhin edited this page Aug 12, 2024 · 6 revisions

deadkey ( keyLabel )

KeyLabel : any valid label for a physical key.

This sets the active deadkey to 'KeyLabel', alters the following key, IF there is a combo for it.

Setting the deadkey has zero effect, unless there is a matching COMBO that looks for that deadkey.

The key X and the deadkey-X are separate things. Deadkeys reuse characters, because I find "deadkey-G" easier to memorize than a number like "deadkey-17".

A matching combo must start with COMBO deadkey-KeyLabel

Usage

"dead keys" are keys which do nothing on their own, but they do alter the following key.
They are most useful to define accented characters.
Common use is to define one deadkey for each accent (like 'G' for accent Grave),
then define a deadkey+key combo for each character that can be combined with the accent, e.g.
with deadkey ` G: aeiou -> àèìòù
with deadkey ^ C: aeiou -> âêîôû
with deadkey ~ T: ano -> ãñõ

Note that deadkey(~) is not valid, since ~ is not a key. You could use deadkey(T) for 'Tilde' instead.

If you want to define many accented characters, copy the relevant section from my default ini, and adjust the combos that set deadkeys to your liking.

Bottom line You need these pieces:

  1. a key combo (anything you like) that sets
  2. deadkey(X) (any key you like), and a
  3. combo that looks for deadkey-X AND key to be accented, and if there is a match, a
  4. resulting accented key (can be created with altChar)

Example

LCtrl+U, then press [A] -> "Ä" , or LCtrl+U then [O] -> Ö is configured with these lines:

COMBO U [..&.] > deadkey(X)  # X can be any valid key label, it is only used to connect a related combo.
COMBO deadkey-X  A []  >  altChar(142) # "match if deadkey X was set, A is pressed, modifiers dont matter"
COMBO deadkey-X  O []  >  altChar(153) # "match if deadkey X was set, O is pressed, modifiers dont matter"

Chained deadkeys

You can combine deadkeys to 'compose' several keys to one result.

Example: Tap LCTRL, then press F, Y, I results in "for your info" :

COMBO F [.... ..T.] > deadkey(F)
COMBO deadkey-F Y [] > deadkey(Y)
COMBO deadkey-Y I [] > sequence(f_o_r_SPACE_y_o_u_r_SPACE_i_n_f_o)

This is inelegant and not designed for intense use, but it works.
I'm not using this myself. Start a discussion if you need this.

A new keyword would be nicer for that like COMPOSE F Y I [T...] > print("For your info")

Background

Dead keys were invented long ago with typewriters. European languages have a lot of accents that are not used in English.

A dead key like [^] would hammer an ^ onto the paper, but would NOT move the paper to the next position like normal keys.
The next key would then hammer into the same position again, so dead ^ then e results in ê.
Implementing all this logic not in code, but in metal levers, springs and cogs, is something I deeply respect. These Olivetti engineers were wizards.

The Windows standard to use dead keys is to switch input language to "US-International".
For example, for Umlauts, you would type ",U for Ü.
A side effect is that " is now dead, you have to type ", Space to produce ". Which drives me bonkers, I cannot live with this.

My recommendation for configuring accented chars

Any characters that you type often as part of words must be either on a plain key or modifier+key. Anything else (tappings, multi mod combos) breaks your typing rhythm. I configured Alt + ;'[ for öäü since I need this often.

Characters for French I put on 'tapped Alt, deadkey, baseCharacter'. It's a bit slow but I don't write French often or fluently anyway.

Characters that I need only occasionally so I can greet my Brazilian and Swedish colleagues properly (Holá Niña and Øle),
I move those out of the way to 'tapped Alt, Shift + deadkey, base Character, so I don't trigger anything if I hit the wrong deadkey.
I don't use this often, but I'm happy so far.