Stop printing garbage characters for F1,F2.. keys (#12835)

This commit is contained in:
Tommaso Sciortino
2025-11-10 10:56:05 -08:00
committed by GitHub
parent 2136598e87
commit 3c9052a751
10 changed files with 70 additions and 18 deletions
@@ -224,6 +224,7 @@ function bufferPaste(
meta: false,
shift: false,
paste: true,
insertable: true,
sequence: buffer,
});
}
@@ -273,6 +274,7 @@ function* emitKeys(
let meta = false;
let shift = false;
let code = undefined;
let insertable = false;
if (ch === ESC) {
escaped = true;
@@ -455,6 +457,7 @@ function* emitKeys(
} else if (ch === ' ') {
name = 'space';
meta = escaped;
insertable = true;
} else if (!escaped && ch <= '\x1a') {
// ctrl+letter
name = String.fromCharCode(ch.charCodeAt(0) + 'a'.charCodeAt(0) - 1);
@@ -464,6 +467,7 @@ function* emitKeys(
name = ch.toLowerCase();
shift = /^[A-Z]$/.exec(ch) !== null;
meta = escaped;
insertable = true;
} else if (MAC_ALT_KEY_CHARACTER_MAP[ch] && process.platform === 'darwin') {
name = MAC_ALT_KEY_CHARACTER_MAP[ch];
meta = true;
@@ -479,12 +483,16 @@ function* emitKeys(
meta,
shift,
paste: false,
insertable: false,
sequence: ESC,
});
} else if (escaped) {
// Escape sequence timeout
name = ch.length ? undefined : 'escape';
meta = true;
} else {
// Any other character is considered printable.
insertable = true;
}
if (
@@ -497,6 +505,7 @@ function* emitKeys(
meta,
shift,
paste: false,
insertable,
sequence,
});
}
@@ -510,6 +519,7 @@ export interface Key {
meta: boolean;
shift: boolean;
paste: boolean;
insertable: boolean;
sequence: string;
}