Skip to content

Commit

Permalink
Merge pull request #4290 from JasonXJ/alt-space
Browse files Browse the repository at this point in the history
Send corresponding escape code for alt+space and ctrl+alt+space
  • Loading branch information
Tyriar committed Dec 7, 2022
2 parents 497df06 + 7f64fa9 commit fe30cd6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/common/input/Keyboard.test.ts
Expand Up @@ -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', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/common/input/Keyboard.ts
Expand Up @@ -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
Expand Down

0 comments on commit fe30cd6

Please sign in to comment.