}
break;
// F1-F12
- case 112: result.key = '\x1bOP'; break;
- case 113: result.key = '\x1bOQ'; break;
- case 114: result.key = '\x1bOR'; break;
- case 115: result.key = '\x1bOS'; break;
- case 116: result.key = '\x1b[15~'; break;
- case 117: result.key = '\x1b[17~'; break;
- case 118: result.key = '\x1b[18~'; break;
- case 119: result.key = '\x1b[19~'; break;
- case 120: result.key = '\x1b[20~'; break;
- case 121: result.key = '\x1b[21~'; break;
- case 122: result.key = '\x1b[23~'; break;
- case 123: result.key = '\x1b[24~'; break;
+ case 112:
+ if (modifiers) {
+ result.key = '\x1b[1;' + (modifiers + 1) + 'P';
+ } else {
+ result.key = '\x1bOP';
+ }
+ break;
+ case 113:
+ if (modifiers) {
+ result.key = '\x1b[1;' + (modifiers + 1) + 'Q';
+ } else {
+ result.key = '\x1bOQ';
+ }
+ break;
+ case 114:
+ if (modifiers) {
+ result.key = '\x1b[1;' + (modifiers + 1) + 'R';
+ } else {
+ result.key = '\x1bOR';
+ }
+ break;
+ case 115:
+ if (modifiers) {
+ result.key = '\x1b[1;' + (modifiers + 1) + 'S';
+ } else {
+ result.key = '\x1bOS';
+ }
+ break;
+ case 116:
+ if (modifiers) {
+ result.key = '\x1b[15;' + (modifiers + 1) + '~';
+ } else {
+ result.key = '\x1b[15~';
+ }
+ break;
+ case 117:
+ if (modifiers) {
+ result.key = '\x1b[17;' + (modifiers + 1) + '~';
+ } else {
+ result.key = '\x1b[17~';
+ }
+ break;
+ case 118:
+ if (modifiers) {
+ result.key = '\x1b[18;' + (modifiers + 1) + '~';
+ } else {
+ result.key = '\x1b[18~';
+ }
+ break;
+ case 119:
+ if (modifiers) {
+ result.key = '\x1b[19;' + (modifiers + 1) + '~';
+ } else {
+ result.key = '\x1b[19~';
+ }
+ break;
+ case 120:
+ if (modifiers) {
+ result.key = '\x1b[20;' + (modifiers + 1) + '~';
+ } else {
+ result.key = '\x1b[20~';
+ }
+ break;
+ case 121:
+ if (modifiers) {
+ result.key = '\x1b[21;' + (modifiers + 1) + '~';
+ } else {
+ result.key = '\x1b[21~';
+ }
+ break;
+ case 122:
+ if (modifiers) {
+ result.key = '\x1b[23;' + (modifiers + 1) + '~';
+ } else {
+ result.key = '\x1b[23~';
+ }
+ break;
+ case 123:
+ if (modifiers) {
+ result.key = '\x1b[24;' + (modifiers + 1) + '~';
+ } else {
+ result.key = '\x1b[24~';
+ }
+ break;
default:
// a-z and space
if (ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) {
it('should return \\x1b[5B for alt+down', function() {
assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 40 }).key, '\x1b[1;5B'); // CSI 5 B
});
+ it('should return the correct escape sequence for modified F1-F12 keys', function() {
+ assert.equal(xterm.evaluateKeyEscapeSequence({ shiftKey: true, keyCode: 112 }).key, '\x1b[1;2P');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ shiftKey: true, keyCode: 113 }).key, '\x1b[1;2Q');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ shiftKey: true, keyCode: 114 }).key, '\x1b[1;2R');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ shiftKey: true, keyCode: 115 }).key, '\x1b[1;2S');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ shiftKey: true, keyCode: 116 }).key, '\x1b[15;2~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ shiftKey: true, keyCode: 117 }).key, '\x1b[17;2~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ shiftKey: true, keyCode: 118 }).key, '\x1b[18;2~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ shiftKey: true, keyCode: 119 }).key, '\x1b[19;2~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ shiftKey: true, keyCode: 120 }).key, '\x1b[20;2~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ shiftKey: true, keyCode: 121 }).key, '\x1b[21;2~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ shiftKey: true, keyCode: 122 }).key, '\x1b[23;2~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ shiftKey: true, keyCode: 123 }).key, '\x1b[24;2~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 112 }).key, '\x1b[1;3P');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 113 }).key, '\x1b[1;3Q');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 114 }).key, '\x1b[1;3R');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 115 }).key, '\x1b[1;3S');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 116 }).key, '\x1b[15;3~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 117 }).key, '\x1b[17;3~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 118 }).key, '\x1b[18;3~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 119 }).key, '\x1b[19;3~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 120 }).key, '\x1b[20;3~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 121 }).key, '\x1b[21;3~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 122 }).key, '\x1b[23;3~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 123 }).key, '\x1b[24;3~');
+
+ assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 112 }).key, '\x1b[1;5P');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 113 }).key, '\x1b[1;5Q');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 114 }).key, '\x1b[1;5R');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 115 }).key, '\x1b[1;5S');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 116 }).key, '\x1b[15;5~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 117 }).key, '\x1b[17;5~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 118 }).key, '\x1b[18;5~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 119 }).key, '\x1b[19;5~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 120 }).key, '\x1b[20;5~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 121 }).key, '\x1b[21;5~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 122 }).key, '\x1b[23;5~');
+ assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 123 }).key, '\x1b[24;5~');
+ });
});
describe('attachCustomEventHandler', function () {