loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / TERMINAL ALIASES FROM WEFT

KeyEvent

Separates the logical key, modifier bits, press/repeat/release phase, produced text, shifted key, and base-layout key. Optional layout/text fields depend on terminal protocol support. Ignore .release when your app acts only on key presses.

loom.KeyEvent is an alias for weft.KeyEvent. It is available through import loom. The underlying type’s members are documented here.

Standard inherited Swift protocol operations such as synthesized equality and OptionSet set operations are not repeated. The public declarations below are extracted from the exact source revision listed in the coverage manifest.

Example

let event = KeyEvent(key: .character("c"), modifiers: [.control])
_ = event.kind != .release && event.modifiers.contains(.control)
Members on this page

Feature guides and release status

KeyEvent

Type Alias
typealias KeyEvent = weft.weft.KeyEvent

Separates the logical key, modifier bits, press/repeat/release phase, produced text, shifted key, and base-layout key. Optional layout/text fields depend on terminal protocol support. Ignore .release when your app acts only on key presses.

Source · TerminalExports.swift:14

Underlying weft API

KeyEvent

Structure
struct KeyEvent

Conforms to: Swift.Equatable, Swift.Sendable, Swift.SendableMetatype.

A key with modifiers and an optional repeat/release phase.

Source · KeyEvent.swift:27

key

Instance Property
let key: Key

The logical key identity.

Source · KeyEvent.swift:28

modifiers

Instance Property
let modifiers: KeyModifiers

Modifier and lock bits supplied by the terminal.

Source · KeyEvent.swift:29

kind

Instance Property
let kind: KeyEventKind

The event’s keyboard phase or mouse action.

Source · KeyEvent.swift:30

text

Instance Property
let text: String?

Text produced by the key, when supplied by the terminal.

Source · KeyEvent.swift:32

shiftedKey

Instance Property
let shiftedKey: Key?

The shifted key in the current keyboard layout, when reported.

Source · KeyEvent.swift:34

baseLayoutKey

Instance Property
let baseLayoutKey: Key?

The physical key in the standard layout, useful for matching shortcuts.

Source · KeyEvent.swift:36

init(key:modifiers:kind:text:shiftedKey:baseLayoutKey:)

Initializer
init(key: Key, modifiers: KeyModifiers = [], kind: KeyEventKind = .press, text: String? = nil, shiftedKey: Key? = nil, baseLayoutKey: Key? = nil)

Creates a value with the supplied arguments. Default arguments are shown in the declaration.

Parameters (6)
key
Logical key to handle.
modifiers
Argument type and any default are shown in the declaration; see the behavior notes above.
kind
Argument type and any default are shown in the declaration; see the behavior notes above.
text
Source text.
shiftedKey
Argument type and any default are shown in the declaration; see the behavior notes above.
baseLayoutKey
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · KeyEvent.swift:38