Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/browser/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ export class Terminal extends CoreTerminal implements ITerminal {
*/
private _keyDownHandled: boolean = false;

/**
* Records whether a keydown event has occured since the last keyup event, i.e. whether a key
* is currently "pressed".
*/
private _keyDownSeen: boolean = false;

/**
* Records whether the keypress event has already been handled and triggered a data event, if so
* the input event should not trigger a data event but should still print to the textarea so
Expand Down Expand Up @@ -1083,6 +1089,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
*/
protected _keyDown(event: KeyboardEvent): boolean | undefined {
this._keyDownHandled = false;
this._keyDownSeen = true;

if (this._customKeyEventHandler && this._customKeyEventHandler(event) === false) {
return false;
Expand Down Expand Up @@ -1168,6 +1175,8 @@ export class Terminal extends CoreTerminal implements ITerminal {
}

protected _keyUp(ev: KeyboardEvent): void {
this._keyDownSeen = false;

if (this._customKeyEventHandler && this._customKeyEventHandler(ev) === false) {
return;
}
Expand Down Expand Up @@ -1241,7 +1250,8 @@ export class Terminal extends CoreTerminal implements ITerminal {
protected _inputEvent(ev: InputEvent): boolean {
// Only support emoji IMEs when screen reader mode is disabled as the event must bubble up to
// support reading out character input which can doubling up input characters
if (ev.data && ev.inputType === 'insertText' && !ev.composed && !this.optionsService.rawOptions.screenReaderMode) {
// Based on these event traces: https://github.com/xtermjs/xterm.js/issues/3679
if (ev.data && ev.inputType === 'insertText' && (!ev.composed || !this._keyDownSeen) && !this.optionsService.rawOptions.screenReaderMode) {
if (this._keyPressHandled) {
return false;
}
Expand Down