我想在用户按shift + tab时执行操作,但是当我检查key.shift的值时,它是false。这是为什么?有没有办法捕捉shift + tab?这是我用来发现这个的代码:
const readline = require('readline');
readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
process.stdin.on('keypress', (str, key) => {
if (key.ctrl && key.name === 'c') {
process.exit();
} else {
console.log(key);
}
});
console.log('Press any key...');
shift + tab上面的输出是:
Press any key...
{ sequence: '\t',
name: 'tab',
ctrl: false,
meta: false,
shift: false }