These docs describe the main branch, including unreleased changes. Read the 0.6.0 docs.

@opentui/keymap/extras

Every export of @opentui/keymap/extras in the main-branch source, from its type declarations. A version names the release that added an export after the module's first release.

Functions#

function commandBindings<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent>(bindings: Readonly<CommandBindingMap>, options?: CommandBindingsOptions): Binding<TTarget, TEvent>[]
Core engine
function createBindingLookup<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent>(config: BindingConfig<TTarget, TEvent>, options?: CreateBindingLookupOptions<TTarget, TEvent>): BindingLookup<TTarget, TEvent>
Core engine
function formatCommandBindings(bindings: readonly SequenceBindingLike[] | undefined, options?: FormatCommandBindingsOptions): string | undefined
Core engine
function formatKeySequence(parts: readonly KeySequenceFormatPart[] | undefined, options?: FormatKeySequenceOptions): string
Core engine

Interfaces#

interface BindingDefaultsContext<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent>
Core engine
  • property BindingDefaultsContext.binding: Readonly<Binding<TTarget, TEvent>>
  • property BindingDefaultsContext.command: string
interface BindingLookup<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent>
Core engine
  • method BindingLookup.gather(name: string, commands: readonly string[]): readonly Binding<TTarget, TEvent>[]
  • method BindingLookup.get(command: string): readonly Binding<TTarget, TEvent>[]
  • method BindingLookup.has(command: string): boolean
  • method BindingLookup.invalidate(name?: string): void
  • method BindingLookup.omit(name: string, commands: readonly string[]): Binding<TTarget, TEvent>[]
  • method BindingLookup.pick(name: string, commands: readonly string[]): Binding<TTarget, TEvent>[]
  • method BindingLookup.update(config?: BindingConfig<TTarget, TEvent>): void
  • readonly property BindingLookup.bindings: readonly Binding<TTarget, TEvent>[]
interface CommandBindingsError
Core engine
  • property CommandBindingsError.code: "invalid-command-binding"
  • property CommandBindingsError.command: string
  • property CommandBindingsError.reason: Error
  • property CommandBindingsError.value: unknown
interface CommandBindingsOptions
Core engine
  • property CommandBindingsOptions.onError?: (error: CommandBindingsError) => void
  • property CommandBindingsOptions.onWarning?: (warning: CommandBindingsOverrideWarning) => void
interface CommandBindingsOverrideWarning
Core engine
  • property CommandBindingsOverrideWarning.code: "command-binding-override"
  • property CommandBindingsOverrideWarning.command: string
  • property CommandBindingsOverrideWarning.nextKey: KeyLike
  • property CommandBindingsOverrideWarning.previousKey: KeyLike
interface CreateBindingLookupOptions<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent>
Core engine
  • property CreateBindingLookupOptions.bindingDefaults?: BindingDefaults<TTarget, TEvent>
  • property CreateBindingLookupOptions.commandMap?: BindingCommandMap
interface FormatCommandBindingsOptions extends FormatKeySequenceOptions
Core engine
  • property FormatCommandBindingsOptions.bindingSeparator?: string
  • property FormatCommandBindingsOptions.dedupe?: boolean
interface FormatKeySequenceOptions
Core engine
  • property FormatKeySequenceOptions.keyNameAliases?: Readonly<Record<string, string>>
  • property FormatKeySequenceOptions.modifierAliases?: Partial<Record<KeyModifierName, string>>
  • property FormatKeySequenceOptions.patternDisplay?: PatternDisplayResolver
  • property FormatKeySequenceOptions.separator?: string
  • property FormatKeySequenceOptions.tokenDisplay?: TokenDisplayResolver
interface KeySequenceFormatPart
Core engine
  • property KeySequenceFormatPart.display: string
  • property KeySequenceFormatPart.match?: KeySequencePart["match"]
  • property KeySequenceFormatPart.patternName?: string
  • property KeySequenceFormatPart.stroke: KeySequencePart["stroke"]
  • property KeySequenceFormatPart.tokenName?: string
interface SequenceBindingLike
Core engine
  • property SequenceBindingLike.sequence: readonly KeySequenceFormatPart[]

Types#

type BindingCommandMap = Readonly<Record<string, string>>
Core engine
type BindingConfig<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent> = Readonly<Record<string, BindingValue<TTarget, TEvent>>>
Core engine
type BindingConfigItem<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent> = KeyLike | Binding<TTarget, TEvent>
Core engine
type BindingDefaults<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent> = (ctx: BindingDefaultsContext<TTarget, TEvent>) => Readonly<Record<string, unknown>> | void
Core engine
type BindingValue<TTarget extends object = object, TEvent extends KeymapEvent = KeymapEvent> = false | "none" | BindingConfigItem<TTarget, TEvent> | readonly BindingConfigItem<TTarget, TEvent>[]
Core engine
type CommandBindingMap = Record<string, KeyLike>
Core engine
type KeyModifierName = "ctrl" | "shift" | "meta" | "super" | "hyper"
Core engine
type TokenDisplayResolver = Readonly<Record<string, string>> | ((tokenName: string, part: KeySequenceFormatPart) => string | undefined)
Core engine