Pular para o conteúdo

Assigning Keys and Layers

Este conteúdo não está disponível em sua língua ainda.

When your board already has the keys you need, bindings describe what they type. Layers let the same key do something else when Shift or another activator is in use. This also lets different physical keys type the same text, or one key type a string.

For example, Neon’s layout file gives its two Y keys distinct IDs and binds both to the same letter.

Layer activators · Keysets · Notes

Layer activators

MOshiftwhen the next typed key is in shift_right
MOshiftwhen the next typed key is in shift_left

Keysets

shift_rightRight-hand keys
shift_leftLeft-hand keys except

Notes

KeysDetails
This key is absent from the original source.

The base layer binds both yl and yr to lowercase “y”. The Shift layer inherits those bindings and uses a case map to produce uppercase “Y” from either key.

[layers.base]
inferred = [ "'" ]
default = "literal"
bindings = {
yl = "y",
yr = "y",
lsh = { layer = "shift", type = "momentary", anchors = "shift_right" },
rsh = { layer = "shift", type = "momentary", anchors = "shift_left" },
ralt = "e",
}
[layers.shift]
inferred = [ "'" ]
default = "transparent"
case_map = "us-english"

The layers use default, inferred, bindings, case_map. The Shift bindings specify a momentary action, a target layer, and anchors.

Neon uses momentary Shift: a matching activation lasts while held. A standalone one_shot can arm a layer for the next ordinary key when tapped; lock toggles the layer. A tap_hold lets the same physical key have distinct tap and hold actions. When a binding produces several characters, a held case map transforms each character; a one-shot map transforms only the first.

Field or formWhat it does
layers.NAME.defaultliteral outputs the key ID, none stops lookup without text, and transparent continues lookup.
layers.NAME.gridPlaces bindings in retained board order. Omit skipped board slots; none describes a key that exists and has no behavior, and ____ is transparent.
layers.NAME.bindingsExplicit key-ID overrides. Quote non-ASCII IDs and IDs containing punctuation as needed. Use { type = "output", value = "none" } to type the reserved word literally.
case_mapUse a preset such as "us-english", a list of two-character pairs such as ["aA", "bB", "2@"], or { use = "us-english", except = ["'"] } to leave the listed source characters unchanged. A character cannot belong to multiple pairs.
source_layerSource layer for mapped transparency. The default is base. Name a different existing layer without its own case map. Explicit destination bindings bypass the map.
active_whenA list of two or more distinct layers that must all be active.

To give each Shift key the opposite hand as its anchors, Neon names two groups of physical keys: uses the right-hand set, and uses the left-hand set, excluding .

[key_sets]
shift_left = { hand = "left", except = [ "spc" ] }
shift_right = { hand = "right" }

The key_sets table selects keys by hand and removes named keys with except.

A set can list key IDs directly or select keys by hand, finger, or a layer’s explicit bindings. You can also reference earlier sets and combine sets with union, intersection, or difference. A named set must resolve to at least one key. See Key-set forms and Binding behaviors for the accepted fields.

Layer defaults apply to single keys. See Defining combos for the separate rules on inheriting combos.

For a physical binding whose legend should differ from its output, add label to an explicit output or none object. A none binding can display a name without typing it; blocked instead refuses the current action. A physical legend does not change analysis, and is not accepted on repeat bindings, tap-hold branches, or contextual outcomes.

Layers and lookup#

A base layer is required. It is always first; other layers retain their authored order.

Later authored layers have higher precedence. Lookup starts at the highest active layer. An unmapped transparent entry continues to the next lower active layer; inactive layers are skipped. A mapped transparent entry instead reads its named source, which defaults to base and need not be active. The first explicit output, activation, repeat behavior, contextual behavior, or none entry stops ordinary lookup.

Default-form layer#

layers.*.default

literal makes every unbound key output its stable key ID. none makes it produce nothing. transparent inherits from the case-map source on a mapped layer, or continues through lower active layers otherwise.

The base layer cannot contain transparent physical or combo behavior because there is no lower layer.

Fragment: compact base and Shift layers
[layers.base]
default = "literal"
bindings = { lsh = { type = "momentary", layer = "shift" } }

[layers.shift]
default = "transparent"
case_map = "us-english"

Grid-form layer#

layers.*.grid

A single string means the rows group. A grouped object must match every nonempty key-grid group and cannot introduce another group.

After key-grid skip slots and completely empty rows are removed, each layer row must have the same number of tokens. Tokens are literal outputs or aliases local to this layer. Every alias must be used.

Fragment: sparse grid with an alias
[layers.symbol]
grid = '''
none none none
excl at hash
'''
bindings = { excl = "!", at = "@", hash = "#" }

Layer bindings#

layers.*.bindings.*

With default, keys are stable key IDs. With grid, keys are aliases used by that grid. See Binding behaviors for accepted values.

Layer inferred keys#

layers.*.inferred = ["minus"]

Records that these physical key positions are absent from the original source on this layer. Every ID must exist in the physical key grid.

This is layer-local metadata, not a behavior change. It does not propagate through transparent lookup or case mapping.

Fragment: source provenance on one layer
[layers.base]
default = "literal"
inferred = ["minus"]

Binding behaviors#

String output and reserved strings#

key = "text"

A plain string emits itself, except: spc emits one space, none is no behavior, ____ is transparent, and skip is valid only in the key grid.

The string transparent emits “transparent”. Use { type = "transparent" } for transparent behavior. To emit any reserved spelling literally, use an output object.

Explicit output#

{ type = "output", value = "text" }

Emits a nonempty literal string. This is also the escape for literal reserved text.

Explicit output value#

value = "text"

The nonempty literal text emitted by an output object.

No behavior#

{ type = "none" }

Stops lookup and produces no output. The shorthand plain string is none.

Transparent lookup#

{ type = "transparent" }

Continues lookup through lower active layers. The grid shorthand is ____.

Without a case map, ordinary lookup continues through lower active layers. On a mapped destination, transparent behavior consults source_layer instead; explicit destination behavior bypasses the source and map.

Layer activation type#

type = "momentary" | "one_shot" | "lock"

momentary keeps a layer active while held. Tap a standalone one_shot key or chord to arm the layer for the next ordinary key, or hold it to use the layer across multiple keys. Inside a tap branch or contextual default, one_shot only arms the layer. lock toggles a layer until the same key or chord toggles it off.

Activation target layer#

layer = "shift"

Names the layer activated by this binding.

Anchor keys#

anchors = "shift_left" | ["a", "b"]

Constrains entry into a momentary or one-shot layer to a named key set or listed stable keys. It does not constrain release. Omission leaves entry unrestricted. Lock activations do not accept anchors.

Tap-hold#

type = "tap_hold"

Branches must use object syntax. A tap accepts output, repeat, skip-repeat, none, blocked, one-shot, or lock activation. A hold accepts output, repeat, skip-repeat, momentary, or lock activation; it does not accept none, blocked, transparent, another tap-hold, or contextual behavior. A contextual rule selects a tap branch with branch = "tap".

Fragment: tap a letter, hold a layer
e = { type = "tap_hold", tap = { type = "output", value = "e" }, hold = { type = "momentary", layer = "sym" } }

Tap-hold tap branch#

tap = {...}

Defines the tap action. It accepts explicit output, repeat, skip-repeat, none, blocked, one-shot, or lock activation object syntax.

Tap-hold hold branch#

hold = {...}

Defines the hold action. It accepts explicit output, repeat, skip-repeat, momentary activation, or lock activation object syntax. Contextual rules cannot select this branch.

Chords and key sets#

Explicit key set#

key_sets.* = ["a", "b"]

Lists retained physical keys directly. IDs cannot repeat. An empty literal is allowed inside a compound expression, but every complete named key set must resolve to at least one key.

Hand-derived key set#

key_sets.*.hand = "left" | "right"

Selects retained main and thumb keys assigned to one hand. The optional except field removes named physical keys from that result.

Hand-derived key-set exclusions#

key_sets.*.except = ["spc"]

Removes retained main or thumb keys from a hand-derived set. Every listed key must exist.

Finger-derived key set#

key_sets.*.finger = "left_index"

Selects retained keys assigned to one exact finger. Thumb selectors use left_thumb or right_thumb.

Layer-derived key set#

key_sets.*.layer = "symbols"

Selects physical keys with an authored binding on the named layer other than none or transparent. It does not inherit output from lower layers, apply a case map, or include keys merely because they belong to a combo. A contextual binding is included because that key has behavior on the layer even when the layer default is none.

The layer may appear later in the document, but it must exist.

Referenced key set#

key_sets.*.ref = "letters"

Reuses the resolved members of an earlier key-set declaration. References to the same declaration, a later declaration, or an unknown name are rejected.

Key-set union#

key_sets.*.union = [{ ref = "letters" }, { finger = "left_thumb" }]

Combines the members produced by zero or more nested key-set expressions and removes duplicates. An empty union resolves to an empty intermediate result.

Key-set intersection#

key_sets.*.intersect = [{ ref = "letters" }, { hand = "left" }]

Keeps keys present in every nested expression. An empty intersection resolves to an empty intermediate result.

Key-set difference#

key_sets.*.diff = [{ ref = "letters" }, ["q", "z"]]

Starts with the first expression and removes every key produced by the second. Use difference for exclusions beyond the concise hand form; there is no absolute complement operator.

Compound key-set rules#

[key_sets]

Union, intersection, and difference operands may recursively use any key-set form, including another compound expression. Empty literals and empty compound results are legal while evaluating a larger expression. After the complete expression is resolved, every named key set must contain at least one retained key.

Each expression object chooses exactly one form. Combining fields such as hand and finger in the same object is invalid.

Case maps#

Case maps are directional grapheme substitutions contributed by an active destination layer. They are normally paired with transparent behavior on a Shift layer.

US-English case map#

layers.*.case_map = "us-english"

Maps a through z to uppercase and applies the punctuation pairs shown below.

US-English punctuation pairs
source:  ` 1 2 3 4 5 6 7 8 9 0 - = [ ] \ ; ' , . /
target:  ~ ! @ # $ % ^ & * ( ) _ + { } | : " < > ?

Bépo 1.0 case map#

layers.*.case_map = "bepo-1.0"

Maps direct base output to Shift output for the Bépo 1.0 convention, as specified by xkeyboard-config fr(bepo). It is distinct from bepo_afnor and from a general French uppercase operation. The exact 48 pairs are shown below.

The final pair is U+0020 Space → U+00A0 No-Break Space. The “ê” to “Ê” pair describes the source convention; selecting this map does not add an ISO key to an ANSI board. AltGr and Shift+AltGr outputs are authored separately.

A dead key or none has no text to transform. Keep direct Shift exceptions such as the circumflex dead key’s !, no-output bindings, and modifier activators explicit. Characters absent from this map stay unchanged. Corpus alphabet normalization is a separate choice.

Exact Bépo 1.0 base-to-Shift pairs
case_map = [
  "$#", "\"1", "«2", "»3", "(4", ")5", "@6", "+7",
  "-8", "/9", "*0", "=°", "%`", "bB", "éÉ", "pP",
  "oO", "èÈ", "vV", "dD", "lL", "jJ", "zZ", "wW",
  "aA", "uU", "iI", "eE", ",;", "cC", "tT", "sS",
  "rR", "nN", "mM", "çÇ", "êÊ", "àÀ", "yY", "xX",
  ".:", "kK", "'?", "qQ", "gG", "hH", "fF", " \u00a0",
]

Custom case pairs#

layers.*.case_map = ["aA", "2@"]

Each string contains exactly two Unicode grapheme clusters: source then target. Endpoints must differ, and no endpoint may appear in another pair.

Case-map preset#

layers.*.case_map.use = "us-english"

Selects the built-in map used by the preset object form. The accepted presets are us-english and bepo-1.0.

Preset exclusions#

layers.*.case_map.except = ["'"]

Removes mappings from the selected preset by source grapheme. Every excluded source must exist in the selected preset.

Conjunctive layer activation#

layers.*.active_when = ["shift", "symbols"]

Declares a derived layer that is active exactly while every named primitive layer is active. Conditions contain at least two distinct non-base primitive layers; derived layers cannot be activated directly or used as prerequisites.

A case-mapped derived layer has exactly two prerequisites. Its explicit source_layer names one prerequisite; the other owns case lifetime, including one-shot mapping of only the first grapheme.

Case-map source layer#

layers.*.source_layer = "a2"

Names the layer whose authored key or combo behavior supplies transparent entries on this mapped destination. The source may appear before or after the destination and does not need to be active.

The source must exist, differ from the destination, and have no case map of its own. Omission selects base, even when other layers between base and the destination are active.

An explicit destination behavior bypasses the source and this case map. At a transparent destination, an explicit source output or contextual behavior is mapped. A source none or absent combo is opaque. A source transparent entry stays transparent, then ordinary active-layer lookup continues below the destination without applying this destination’s map.

Fragment: Shift a second alphabet layer
[layers.a2]
default = "literal"
bindings = { a = "x" }

[layers.shift2]
default = "transparent"
case_map = "us-english"
source_layer = "a2"

Mapping and layer lookup#

A map transforms text supplied by a mapped destination’s source layer, including contextual defaults and rule outputs. It maps each grapheme rather than treating a multi-grapheme output as one pair.

A held or locked mapped layer maps the complete inherited output. A one-shot mapped layer maps its first grapheme. Explicit behavior on the mapped destination is unchanged.