fixed macOptionIsMeta on macOS and added Alt-Shift-Letter key handling
This commit is contained in:
@@ -1096,14 +1096,17 @@ export class Terminal extends CoreTerminal implements ITerminal {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._compositionHelper!.keydown(event)) {
|
// Ignore composing with Alt key on Mac when macOptionIsMeta is enabled
|
||||||
|
const shouldIgnoreComposition = this.browser.isMac && this.options.macOptionIsMeta && event.altKey
|
||||||
|
|
||||||
|
if (!shouldIgnoreComposition && !this._compositionHelper!.keydown(event)) {
|
||||||
if (this.buffer.ybase !== this.buffer.ydisp) {
|
if (this.buffer.ybase !== this.buffer.ydisp) {
|
||||||
this._bufferService.scrollToBottom();
|
this._bufferService.scrollToBottom();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === 'Dead' || event.key === 'AltGraph') {
|
if (!shouldIgnoreComposition && (event.key === 'Dead' || event.key === 'AltGraph')) {
|
||||||
this._unprocessedDeadKey = true;
|
this._unprocessedDeadKey = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
@@ -50,6 +50,7 @@ export interface IKeyboardEvent {
|
|||||||
keyCode: number;
|
keyCode: number;
|
||||||
key: string;
|
key: string;
|
||||||
type: string;
|
type: string;
|
||||||
|
code: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IScrollEvent {
|
export interface IScrollEvent {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ function testEvaluateKeyboardEvent(partialEvent: {
|
|||||||
shiftKey?: boolean;
|
shiftKey?: boolean;
|
||||||
metaKey?: boolean;
|
metaKey?: boolean;
|
||||||
keyCode?: number;
|
keyCode?: number;
|
||||||
|
code?: string;
|
||||||
key?: string;
|
key?: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
}, partialOptions: {
|
}, partialOptions: {
|
||||||
@@ -26,6 +27,7 @@ function testEvaluateKeyboardEvent(partialEvent: {
|
|||||||
shiftKey: partialEvent.shiftKey || false,
|
shiftKey: partialEvent.shiftKey || false,
|
||||||
metaKey: partialEvent.metaKey || false,
|
metaKey: partialEvent.metaKey || false,
|
||||||
keyCode: partialEvent.keyCode !== undefined ? partialEvent.keyCode : 0,
|
keyCode: partialEvent.keyCode !== undefined ? partialEvent.keyCode : 0,
|
||||||
|
code: partialEvent.code || '',
|
||||||
key: partialEvent.key || '',
|
key: partialEvent.key || '',
|
||||||
type: partialEvent.type || ''
|
type: partialEvent.type || ''
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -354,7 +354,23 @@ export function evaluateKeyboardEvent(
|
|||||||
result.key = C0.ESC + key;
|
result.key = C0.ESC + key;
|
||||||
} else if (ev.keyCode >= 65 && ev.keyCode <= 90) {
|
} else if (ev.keyCode >= 65 && ev.keyCode <= 90) {
|
||||||
const keyCode = ev.ctrlKey ? ev.keyCode - 64 : ev.keyCode + 32;
|
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) {
|
} else if (isMac && !ev.altKey && !ev.ctrlKey && !ev.shiftKey && ev.metaKey) {
|
||||||
if (ev.keyCode === 65) { // cmd + a
|
if (ev.keyCode === 65) { // cmd + a
|
||||||
|
|||||||
Reference in New Issue
Block a user