fixing arrow key sequences

This commit is contained in:
Jörg Breitbart
2016-07-21 12:39:36 +02:00
parent dc17f0d02e
commit ec7130b46f
+30 -49
View File
@@ -2581,6 +2581,7 @@
// The number of characters to scroll, if this is defined it will cancel the event // The number of characters to scroll, if this is defined it will cancel the event
scrollDisp: undefined scrollDisp: undefined
}; };
var modifiers = ev.shiftKey << 0 | ev.altKey << 1 | ev.ctrlKey << 2 | ev.metaKey << 3;
switch (ev.keyCode) { switch (ev.keyCode) {
// backspace // backspace
case 8: case 8:
@@ -2611,61 +2612,39 @@
break; break;
// left-arrow // left-arrow
case 37: case 37:
if (ev.altKey) { if (modifiers)
result.key = '\x1bb' // Jump a word back result.key = '\x1b[1;' + (modifiers + 1) + 'D';
result.cancel = true; else if (this.applicationCursor)
break; result.key = '\x1bOD';
} else
if (ev.ctrlKey) { result.key = '\x1b[D';
result.key = '\x1b[5D'; // Jump a word back
break;
}
if (this.applicationCursor) {
result.key = '\x1bOD'; // SS3 as ^[O for 7-bit
break;
}
result.key = '\x1b[D';
break; break;
// right-arrow // right-arrow
case 39: case 39:
if (ev.altKey) { if (modifiers)
result.key = '\x1bf' // Jump a word forward result.key = '\x1b[1;' + (modifiers + 1) + 'C';
result.cancel = true; else if (this.applicationCursor)
break;
}
if (ev.ctrlKey) {
result.key = '\x1b[5C'; // Jump a word forward
break;
}
if (this.applicationCursor) {
result.key = '\x1bOC'; result.key = '\x1bOC';
break; else
} result.key = '\x1b[C';
result.key = '\x1b[C';
break; break;
// up-arrow // up-arrow
case 38: case 38:
if (this.applicationCursor) { if (modifiers)
result.key = '\x1b[1;' + (modifiers + 1) + 'A';
else if (this.applicationCursor)
result.key = '\x1bOA'; result.key = '\x1bOA';
break; else
}
if (ev.ctrlKey) {
result.scrollDisp = -1;
} else {
result.key = '\x1b[A'; result.key = '\x1b[A';
}
break; break;
// down-arrow // down-arrow
case 40: case 40:
if (this.applicationCursor) { if (modifiers)
result.key = '\x1b[1;' + (modifiers + 1) + 'B';
else if (this.applicationCursor)
result.key = '\x1bOB'; result.key = '\x1bOB';
break; else
}
if (ev.ctrlKey) {
result.scrollDisp = 1;
} else {
result.key = '\x1b[B'; result.key = '\x1b[B';
}
break; break;
// insert // insert
case 45: case 45:
@@ -2679,19 +2658,21 @@
case 46: result.key = '\x1b[3~'; break; case 46: result.key = '\x1b[3~'; break;
// home // home
case 36: case 36:
if (this.applicationKeypad) { if (modifiers)
result.key = '\x1b[1;' + (modifiers + 1) + 'H';
else if (this.applicationCursor)
result.key = '\x1bOH'; result.key = '\x1bOH';
break; else
} result.key = '\x1b[H';
result.key = '\x1bOH';
break; break;
// end // end
case 35: case 35:
if (this.applicationKeypad) { if (modifiers)
result.key = '\x1b[1;' + (modifiers + 1) + 'F';
else if (this.applicationCursor)
result.key = '\x1bOF'; result.key = '\x1bOF';
break; else
} result.key = '\x1b[F';
result.key = '\x1bOF';
break; break;
// page up // page up
case 33: case 33: