diff --git a/lib/keys.js b/lib/keys.js index df112e4..aceee83 100644 --- a/lib/keys.js +++ b/lib/keys.js @@ -117,7 +117,7 @@ function emitKey(stream, s) { } } - if (~s.indexOf('\x1b[M')) { + if (isMouse(s)) { return; } @@ -314,3 +314,13 @@ function emitKey(stream, s) { // } } } + +function isMouse(s) { + return /\x1b\[M/.test(s) + || /\x1b\[M([\x00\u0020-\uffff]{3})/.test(s) + || /\x1b\[(\d+;\d+;\d+)M/.test(s) + || /\x1b\[<(\d+;\d+;\d+)([mM])/.test(s) + || /\x1b\[<(\d+;\d+;\d+;\d+)&w/.test(s) + || /\x1b\[24([0135])~\[(\d+),(\d+)\]\r/.test(s) + || /\x1b\[(O|I)/.test(s); +} diff --git a/lib/program.js b/lib/program.js index 4f6b31c..d20eeba 100644 --- a/lib/program.js +++ b/lib/program.js @@ -515,7 +515,7 @@ Program.prototype._bindMouse = function(s, buf) { key.action = 'mousemove'; } - self.emit('keypress', null, key); + // self.emit('keypress', null, key); self.emit('mouse', key); return; @@ -585,7 +585,7 @@ Program.prototype._bindMouse = function(s, buf) { key.action = 'mousemove'; } - self.emit('keypress', null, key); + // self.emit('keypress', null, key); self.emit('mouse', key); return; @@ -644,7 +644,7 @@ Program.prototype._bindMouse = function(s, buf) { key.action = 'mousemove'; } - self.emit('keypress', null, key); + // self.emit('keypress', null, key); self.emit('mouse', key); return; @@ -680,7 +680,7 @@ Program.prototype._bindMouse = function(s, buf) { : b === 6 ? 'right' : 'unknown'; - self.emit('keypress', null, key); + // self.emit('keypress', null, key); self.emit('mouse', key); return; @@ -709,7 +709,7 @@ Program.prototype._bindMouse = function(s, buf) { : b === 5 ? 'right' : 'unknown'; - self.emit('keypress', null, key); + // self.emit('keypress', null, key); self.emit('mouse', key); return; @@ -768,7 +768,7 @@ Program.prototype.enableGpm = function() { ctrl: self.gpm.hasCtrlKey(modifier) }; - self.emit('keypress', null, key); + // self.emit('keypress', null, key); self.emit('mouse', key); }); @@ -788,7 +788,7 @@ Program.prototype.enableGpm = function() { ctrl: self.gpm.hasCtrlKey(modifier) }; - self.emit('keypress', null, key); + // self.emit('keypress', null, key); self.emit('mouse', key); }); @@ -808,7 +808,7 @@ Program.prototype.enableGpm = function() { ctrl: self.gpm.hasCtrlKey(modifier) }; - self.emit('keypress', null, key); + // self.emit('keypress', null, key); self.emit('mouse', key); }); @@ -828,7 +828,7 @@ Program.prototype.enableGpm = function() { ctrl: self.gpm.hasCtrlKey(modifier) }; - self.emit('keypress', null, key); + // self.emit('keypress', null, key); self.emit('mouse', key); }); @@ -846,7 +846,7 @@ Program.prototype.enableGpm = function() { ctrl: self.gpm.hasCtrlKey(modifier) }; - self.emit('keypress', null, key); + // self.emit('keypress', null, key); self.emit('mouse', key); }); };