Stringifies key objects emitted by nodejs readline (http://nodejs.org/api/readline.html).
Stringifies key objects emitted by nodejs readline.
Counter part to parse key.
npm i stringify-key
var stringifyKey = ;var key = name: 'c' ctrl: true meta: false shift: false ;console; // ctrl-ckey = name: 'c' ctrl: true meta: true shift: true ;console; // shift-meta-ctrl-c
Although the algorithm works for all keys, the readline module doesn't work consistent in all terminals. For example, on
Mac Lion xTerm the
meta key is never registered.
As just stated the
meta key is not registered (at least in xTerm), however if present,
stringify-key will take it
ctrl key seems to work properly in
readline, except for the following:
ctrl-m, both interpreted as
ctrl-[;',/]are also not interpreted correctly
shift-letter is correctly registered as well, however pressing
ctrl-shift and a letter together registers
Here is the most likely cause for the latter, since letters are never
ctrl is pressed.
There is no code inside the
readline module that registers pressing the
alt in conjunction with a letter is used to enter characters otherwise not available on the keyboard,
However if an
alt : true is part of the passed
key object, it is considered by
I'm not sure if the unexplained problems above are caused by an incorrect implemention in
readline or the underlying terminal.
I suggest to investigate the readline source in order to
get more information and/or fix problems.
In conclusion, the moral is to expect unexpected results (npi) when using
stringify-key for keys emitted by