]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Merge remote-tracking branch 'upstream/master' into 118_support_custom_keydown_handler
authorDaniel Imms <daimms@microsoft.com>
Fri, 15 Jul 2016 23:21:06 +0000 (16:21 -0700)
committerDaniel Imms <daimms@microsoft.com>
Fri, 15 Jul 2016 23:21:06 +0000 (16:21 -0700)
1  2 
src/xterm.js

diff --cc src/xterm.js
index f506e8e14aee823b539500284547119ac74f3573,d88ddf49e7edd2f61b746d75363f4ec70526a376..89473aaf0dde1e42babcad5f422b3369c30aa72a
        this.write(data + '\r\n');
      };
  
-     // Key Resources:
-     // https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
 +    /**
 +     * 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;
 +    }
 +
+     /**
+      * Handle a keydown event
+      * Key Resources:
+      *   - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
+      * @param {KeyboardEvent} ev The keydown event to be handled.
+      */
      Terminal.prototype.keyDown = function(ev) {
 +      if (this.customKeydownHandler && !this.customKeydownHandler(ev)) {
 +        return;
 +      }
        var self = this;
        var result = this.evaluateKeyEscapeSequence(ev);