Skip to main content

Class: KeyboardHandler

keyboard/KeyboardHandler.KeyboardHandler

Allows other components to register to listen to typing events. Note that only one listener can be active at a time, and having any listeners active will cause typing not to work.

Each time pushListener is called, the listener is pushed onto the top of the stack. The cursorless.keyboard.escape action can be used to pop the current listener off the stack, which will call its Listener.handleCancelled function. The next listener on the stack will take over the keyboard, unless the stack is empty, which will give keyboard control back to VSCode.

Constructors

constructor

new KeyboardHandler(graph)

Parameters

NameType
graphGraph

Defined in

keyboard/KeyboardHandler.ts:90

Properties

activeListener

Private activeListener: undefined | ListenerEntry

Defined in

keyboard/KeyboardHandler.ts:85


disposables

Private disposables: Disposable[] = []

Defined in

keyboard/KeyboardHandler.ts:88


isActivated

Private isActivated: boolean = false

Defined in

keyboard/KeyboardHandler.ts:87


listeners

Private listeners: ListenerEntry[] = []

Defined in

keyboard/KeyboardHandler.ts:84


typeCommandDisposable

Private Optional typeCommandDisposable: Disposable

Defined in

keyboard/KeyboardHandler.ts:86

Methods

activateListener

Private activateListener(listenerEntry): void

Parameters

NameType
listenerEntryundefined | ListenerEntry

Returns

void

Defined in

keyboard/KeyboardHandler.ts:231


awaitSingleKeypress

awaitSingleKeypress(displayOptions): Promise<undefined | string>

Convenience method that can be used to wait for a single keypress.

Parameters

NameTypeDescription
displayOptionsDisplayOptionsHow to indicate that this listener is active (eg cursor)

Returns

Promise<undefined | string>

A promise that resolves to the next key pressed by the user, or undefined if cancelActiveListener is called before a keypress (eg if they have cursorless.keyboard.escape bound to escape and they press escape)

Defined in

keyboard/KeyboardHandler.ts:188


cancelActiveListener

cancelActiveListener(): void

Pop active listener of the stack and call its Listener.handleCancelled function

Returns

void

Defined in

keyboard/KeyboardHandler.ts:168


dispose

dispose(): void

Returns

void

Defined in

keyboard/KeyboardHandler.ts:127


disposeOfActiveListener

Private disposeOfActiveListener(): void

Returns

void

Defined in

keyboard/KeyboardHandler.ts:264


ensureCursorStyle

Private ensureCursorStyle(): void

Returns

void

Defined in

keyboard/KeyboardHandler.ts:282


ensureGlobalWhenClauseContext

Private ensureGlobalWhenClauseContext(): void

Returns

void

Defined in

keyboard/KeyboardHandler.ts:316


ensureState

Private ensureState(): void

Called after any input state changes (eg listener pushed), and ensures that the state that we control is as expected. Eg it changes cursor if necessary, sets when clause contexts, etc

Returns

void

Defined in

keyboard/KeyboardHandler.ts:212


ensureStatusBarText

Private ensureStatusBarText(): void

Returns

void

Defined in

keyboard/KeyboardHandler.ts:301


init

init(): void

Returns

void

Defined in

keyboard/KeyboardHandler.ts:95


pushListener

pushListener(listener): Disposable

Registers a listener to take over listening to typing events. Will cause all other listeners, as well as default keyboard input, to stop receiving input until the returned dispose method is called.

Parameters

NameTypeDescription
listenerListenerThe listener to be notified on typing events

Returns

Disposable

A disposable that can be called to remove the listener

Defined in

keyboard/KeyboardHandler.ts:138