diff --git a/lib/components/term.js b/lib/components/term.js
index 0eaf319e..87315994 100644
--- a/lib/components/term.js
+++ b/lib/components/term.js
@@ -61,6 +61,7 @@ export default class Term extends Component {
}
};
+ this.term.modifierKeys = props.modifierKeys;
// this.term.CursorNode_ is available at this point.
this.term.setCursorShape(props.cursorShape);
};
diff --git a/lib/components/terms.js b/lib/components/terms.js
index d0bab64f..66f745b1 100644
--- a/lib/components/terms.js
+++ b/lib/components/terms.js
@@ -152,7 +152,8 @@ export default class Terms extends Component {
onURLAbort: this.bind(this.props.onURLAbort, null, uid),
bell: this.props.bell,
bellSoundURL: this.props.bellSoundURL,
- copyOnSelect: this.props.copyOnSelect
+ copyOnSelect: this.props.copyOnSelect,
+ modifierKeys: this.props.modifierKeys
});
return (
{
diff --git a/lib/hterm.js b/lib/hterm.js
index 03aefc39..9700c789 100644
--- a/lib/hterm.js
+++ b/lib/hterm.js
@@ -102,6 +102,24 @@ hterm.Keyboard.prototype.onKeyDown_ = function (e) {
console.warn('Uncaught dead key on international keyboard', e);
}
+ const modifierKeysConf = this.terminal.modifierKeys;
+ if (e.altKey &&
+ e.code !== 'alt' &&
+ e.code !== 'altLeft' &&
+ e.code !== 'altRight' &&
+ modifierKeysConf.altIsMeta) {
+ this.terminal.onVTKeystroke('\x1b' + String.fromCharCode(e.keyCode));
+ e.preventDefault();
+ }
+
+ if (e.metaKey &&
+ e.code !== 'MetaLeft' &&
+ e.code !== 'MetaRight' &&
+ modifierKeysConf.cmdIsMeta) {
+ this.terminal.onVTKeystroke('\x1b' + String.fromCharCode(e.keyCode));
+ e.preventDefault();
+ }
+
if (e.metaKey || e.altKey || (e.ctrlKey && e.code === 'Tab')) {
return;
}
diff --git a/lib/reducers/ui.js b/lib/reducers/ui.js
index 730a0166..6636849d 100644
--- a/lib/reducers/ui.js
+++ b/lib/reducers/ui.js
@@ -71,7 +71,11 @@ const initial = Immutable({
updateNotes: null,
bell: 'SOUND',
bellSoundURL: 'lib-resource:hterm/audio/bell',
- copyOnSelect: false
+ copyOnSelect: false,
+ modifierKeys: {
+ altIsMeta: false,
+ cmdIsMeta: false
+ }
});
const reducer = (state = initial, action) => {
@@ -157,6 +161,10 @@ const reducer = (state = initial, action) => {
}
}
+ if (config.modifierKeys !== null) {
+ ret.modifierKeys = config.modifierKeys;
+ }
+
return ret;
})());
break;