node.jslibuv

Map or table of libuv converstions to ANSI?


I am trying to fix an implementation of readline for the browser, and it would be nice if I could have the same behaviour that libuv for windows does. I want to know where can I find which keycodes maps to what? For example from https://github.com/nodejs/node/blob/HEAD/lib/internal/readline/utils.js#L232 we know that

fkeymap={
    f1:'[[A',
    f2:'[[B',
    f3:'[[C',
    f4:'[[D',
    f5:'[[E'
}

We can test ourselves this if we run this code in node

var readline = require('readline'),
    rl = readline.createInterface(process.stdin, process.stdout);
process.stdin.on('keypress', function(s, key) {
  console.log("keypress event",{s,key})
});

but if you start combining ctrl and shift codes, you start getting wild ansi combinations, for example ctrl+shift+f9 maps to "\x1b[33^" is this documented somewhere?


Solution

  • I didn't find this table documented anywhere, but I am going to post the data that I got by experimentally trying all the keys in my keyboard available, hope this helps someone. I prefix the keys with 'c' to mean that control was pressed, and 's' to mean that shift was pressed.

    keys={
    f1:"[[A",
    f2:"[[B",
    f3:"[[C",
    f4:"[[D",
    f5:"[[E",
    f6:"[17~",
    f7:"[18~",
    f8:"[19~",
    f9:"[20~",
    f10:"[21~",
    f11:"[23~",
    f12:"[24~",
    cf1:"[11^",
    cf2:"[12^",
    cf3:"[13^",
    cf4:"[14^",
    cf5:"[15^",
    cf6:"[17^",
    cf7:"[18^",
    cf8:"[19^",
    cf9:"[20^",
    cf10:"[21^",
    cf11:"[23^",
    cf12:"[24^",
    sf1:"[23~",
    sf2:"[24~",
    sf3:"[25~",
    sf4:"[26~",
    sf5:"[28~",
    sf6:"[29~",
    sf7:"[31~",
    sf8:"[32~",
    sf9:"[33~",
    sf10:"[34~",
    sf11:"[23$",
    sf12:"[24$",
    csf1:"[23^",
    csf2:"[24^",
    csf3:"[25^",
    csf4:"[26^",
    csf5:"[28^",
    csf6:"[29^",
    csf7:"[31^",
    csf8:"[32^",
    csf9:"[33^",
    csf10:"[34^",
    csf11:"[23@",
    csf12:"[24@",
    home:"[1~",
    insert:"[2~",
    delete:"[3~",
    end:"[4~",
    pageup:"[5~",
    pagedown:"[6~",
    chome:"[1;5~",
    cinsert:"[2;5~",
    cdelete:"[3;5~",
    cend:"[4;5~",
    cpageup:"[5;5~",
    cpagedown:"[6;5~",
    shome:"[1;2~",
    sinsert:"[2;2~",
    sdelete:"[3;2~",
    send:"[4;2~",
    spageup:"[5;2~",
    spagedown:"[6;2~",
    cshome:"[1;6~",
    csinsert:"[2;6~",
    csdelete:"[3;6~",
    csend:"[4;6~",
    cspageup:"[5;6~",
    cspagedown:"[6;6~"
    }