This commit is contained in:
joylink_cuiweidong 2020-09-30 10:16:51 +08:00
commit 082144ee01
3 changed files with 12 additions and 9 deletions

View File

@ -13,16 +13,17 @@ class KeyboardController extends Eventful {
initHandler(zr) {
if (zr) {
var keydownHandle = this.keydown.bind(this);
var dom = this.$zr.dom;
this.enable = function (opts) {
opts = opts || {};
this._keyOnDownUp = opts.keyOnDownUp || true;
window.addEventListener('keyup', keydownHandle, false);
dom.addEventListener('keyup', keydownHandle, false);
};
this.disable = function () {
window.removeEventListener('keyup', keydownHandle, false);
dom.removeEventListener('keyup', keydownHandle, false);
};
this.dispose = function() {

View File

@ -13,19 +13,20 @@ class KeyboardController extends Eventful {
initHandler(zr) {
if (zr) {
var keydownHandle = this.keydown.bind(this);
var keyupHandle = this.keyup.bind(this);
var keyupHandle = this.keyup.bind(this);
var dom = this.$zr.dom;
this.enable = function (opts) {
opts = opts || {};
this._keyOnDownUp = opts.keyOnDownUp || true;
window.addEventListener('keydown', keydownHandle, false);
window.addEventListener('keyup', keyupHandle, false);
dom.addEventListener('keydown', keydownHandle, false);
dom.addEventListener('keyup', keyupHandle, false);
};
this.disable = function () {
window.removeEventListener('keydown', keydownHandle, false);
window.removeEventListener('keyup', keyupHandle, false);
dom.removeEventListener('keydown', keydownHandle, false);
dom.removeEventListener('keyup', keyupHandle, false);
};
this.dispose = function() {

View File

@ -14,16 +14,17 @@ class KeyboardController extends Eventful {
initHandler(zr) {
if (zr) {
var keydownHandle = this.keydown.bind(this);
var dom = this.$zr.dom;
this.enable = function (opts) {
opts = opts || {};
this._keyOnDownUp = opts.keyOnDownUp || true;
window.addEventListener('keyup', keydownHandle, false);
dom.addEventListener('keyup', keydownHandle, false);
};
this.disable = function () {
window.removeEventListener('keyup', keydownHandle, false);
dom.removeEventListener('keyup', keydownHandle, false);
};
this.dispose = function() {