@@ -247,6 +247,7 @@
|
|||||||
this.queue = '';
|
this.queue = '';
|
||||||
this.scrollTop = 0;
|
this.scrollTop = 0;
|
||||||
this.scrollBottom = this.rows - 1;
|
this.scrollBottom = this.rows - 1;
|
||||||
|
this.customKeydownHandler = null;
|
||||||
|
|
||||||
// modes
|
// modes
|
||||||
this.applicationKeypad = false;
|
this.applicationKeypad = false;
|
||||||
@@ -2517,9 +2518,24 @@
|
|||||||
this.write(data + '\r\n');
|
this.write(data + '\r\n');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attaches a custom keydown handler which is run before keys are processed, giving consumers of
|
||||||
|
* xterm.js ultimate control as to what keys should be processed by the terminal and what keys
|
||||||
|
* should not.
|
||||||
|
* @param {function} customKeydownHandler The custom KeyboardEvent handler to attach. This is a
|
||||||
|
* function that takes a KeyboardEvent, allowing consumers to stop propogation and/or prevent
|
||||||
|
* the default action. The function returns whether the event should be processed by xterm.js.
|
||||||
|
*/
|
||||||
|
Terminal.prototype.attachCustomKeydownHandler = function(customKeydownHandler) {
|
||||||
|
this.customKeydownHandler = customKeydownHandler;
|
||||||
|
}
|
||||||
|
|
||||||
// Key Resources:
|
// Key Resources:
|
||||||
// https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
|
// https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
|
||||||
Terminal.prototype.keyDown = function(ev) {
|
Terminal.prototype.keyDown = function(ev) {
|
||||||
|
if (this.customKeydownHandler && !this.customKeydownHandler(ev)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var self = this;
|
var self = this;
|
||||||
var result = this.evaluateKeyEscapeSequence(ev);
|
var result = this.evaluateKeyEscapeSequence(ev);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user