Simplify keyboard event API
No need for an object for three static fields.
This commit is contained in:
@@ -47,10 +47,10 @@ Keyboard.prototype = {
|
||||
// private methods
|
||||
|
||||
_handleRfbEvent: function (e) {
|
||||
if (this._onKeyPress) {
|
||||
Log.Debug("onKeyPress " + (e.type == 'keydown' ? "down" : "up") +
|
||||
if (this._onKeyEvent) {
|
||||
Log.Debug("onKeyEvent " + (e.type == 'keydown' ? "down" : "up") +
|
||||
", keysym: " + e.keysym);
|
||||
this._onKeyPress(e);
|
||||
this._onKeyEvent(e.keysym, e.code, e.type == 'keydown');
|
||||
}
|
||||
},
|
||||
|
||||
@@ -138,7 +138,7 @@ make_properties(Keyboard, [
|
||||
['target', 'wo', 'dom'], // DOM element that captures keyboard input
|
||||
['focused', 'rw', 'bool'], // Capture and send key events
|
||||
|
||||
['onKeyPress', 'rw', 'func'] // Handler for key press/release
|
||||
['onKeyEvent', 'rw', 'func'] // Handler for key press/release
|
||||
]);
|
||||
|
||||
const Mouse = function (defaults) {
|
||||
|
||||
+3
-4
@@ -200,7 +200,7 @@ export default function RFB(defaults) {
|
||||
}
|
||||
|
||||
this._keyboard = new Keyboard({target: this._focusContainer,
|
||||
onKeyPress: this._handleKeyPress.bind(this)});
|
||||
onKeyEvent: this._handleKeyEvent.bind(this)});
|
||||
|
||||
this._mouse = new Mouse({target: this._target,
|
||||
onMouseButton: this._handleMouseButton.bind(this),
|
||||
@@ -664,9 +664,8 @@ RFB.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
_handleKeyPress: function (keyevent) {
|
||||
var down = (keyevent.type == 'keydown');
|
||||
this.sendKey(keyevent.keysym, keyevent.code, down);
|
||||
_handleKeyEvent: function (keysym, code, down) {
|
||||
this.sendKey(keysym, code, down);
|
||||
},
|
||||
|
||||
_handleMouseButton: function (x, y, down, bmask) {
|
||||
|
||||
Reference in New Issue
Block a user