fixed macOptionIsMeta on macOS and added Alt-Shift-Letter key handling
This commit is contained in:
@@ -13,6 +13,7 @@ function testEvaluateKeyboardEvent(partialEvent: {
|
||||
shiftKey?: boolean;
|
||||
metaKey?: boolean;
|
||||
keyCode?: number;
|
||||
code?: string;
|
||||
key?: string;
|
||||
type?: string;
|
||||
}, partialOptions: {
|
||||
@@ -26,6 +27,7 @@ function testEvaluateKeyboardEvent(partialEvent: {
|
||||
shiftKey: partialEvent.shiftKey || false,
|
||||
metaKey: partialEvent.metaKey || false,
|
||||
keyCode: partialEvent.keyCode !== undefined ? partialEvent.keyCode : 0,
|
||||
code: partialEvent.code || '',
|
||||
key: partialEvent.key || '',
|
||||
type: partialEvent.type || ''
|
||||
};
|
||||
|
||||
@@ -354,7 +354,23 @@ export function evaluateKeyboardEvent(
|
||||
result.key = C0.ESC + key;
|
||||
} else if (ev.keyCode >= 65 && ev.keyCode <= 90) {
|
||||
const keyCode = ev.ctrlKey ? ev.keyCode - 64 : ev.keyCode + 32;
|
||||
result.key = C0.ESC + String.fromCharCode(keyCode);
|
||||
let keyString = String.fromCharCode(keyCode);
|
||||
if (ev.shiftKey) {
|
||||
keyString = keyString.toUpperCase();
|
||||
}
|
||||
result.key = C0.ESC + keyString;
|
||||
} 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
|
||||
// of the letters in US layout (e.g. N/E/U).
|
||||
// It's safe to match against Key* since no other `code` values begin with "Key".
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values#code_values_on_mac
|
||||
let keyString = ev.code.slice(3, 4);
|
||||
if (!ev.shiftKey) {
|
||||
keyString = keyString.toLowerCase();
|
||||
}
|
||||
result.key = C0.ESC + keyString;
|
||||
result.cancel = true;
|
||||
}
|
||||
} else if (isMac && !ev.altKey && !ev.ctrlKey && !ev.shiftKey && ev.metaKey) {
|
||||
if (ev.keyCode === 65) { // cmd + a
|
||||
|
||||
Reference in New Issue
Block a user