From 7f64fa9dddb8a2e88e06d3a00bc3eb6db1b009c4 Mon Sep 17 00:00:00 2001 From: Jason Lin Date: Tue, 6 Dec 2022 15:57:19 +1100 Subject: [PATCH] Send corresponding escape code for alt+space and ctrl+alt+space The previous behavior is that this combinations do nothing. --- src/common/input/Keyboard.test.ts | 6 ++++++ src/common/input/Keyboard.ts | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/common/input/Keyboard.test.ts b/src/common/input/Keyboard.test.ts index 68fbaac1e0..f2d0936b3e 100644 --- a/src/common/input/Keyboard.test.ts +++ b/src/common/input/Keyboard.test.ts @@ -125,6 +125,12 @@ describe('Keyboard', () => { it('should return \\x1ba for alt+a', () => { assert.equal(testEvaluateKeyboardEvent({ altKey: true, keyCode: 65 }, { isMac: false }).key, '\x1ba'); }); + it('should return \\x1b\\x20 for alt+space', () => { + assert.equal(testEvaluateKeyboardEvent({ altKey: true, keyCode: 32 }, { isMac: false }).key, '\x1b\x20'); + }); + it('should return \\x1b\\x00 for ctrl+alt+space', () => { + assert.equal(testEvaluateKeyboardEvent({ altKey: true, ctrlKey: true, keyCode: 32 }, { isMac: false }).key, '\x1b\x00'); + }); }); describe('On macOS platforms', () => { diff --git a/src/common/input/Keyboard.ts b/src/common/input/Keyboard.ts index 013a7711f4..225c914e38 100644 --- a/src/common/input/Keyboard.ts +++ b/src/common/input/Keyboard.ts @@ -360,6 +360,8 @@ export function evaluateKeyboardEvent( keyString = keyString.toUpperCase(); } result.key = C0.ESC + keyString; + } else if (ev.keyCode === 32) { + result.key = C0.ESC + (ev.ctrlKey ? C0.NUL : ' '); } else if (ev.key === 'Dead' && ev.code.startsWith('Key')) { // Reference: https://github.com/xtermjs/xterm.js/issues/3725 // Alt will produce a "dead key" (initate composition) with some