Open Tsinswreng opened 3 months ago
keyTap('right_alt') actually send left alt instead of right alt
keyTap('right_alt') should send right alt
keyTap('right_alt')
keyTap('right_alt') sends left alt instead
I use node-global-key-listener to listen to key input.
node-global-key-listener
npm install robotjs npm install node-global-key-listener
const rb = require('robotjs'); const { GlobalKeyboardListener } = require("node-global-key-listener"); const gkl = new GlobalKeyboardListener(); gkl.addListener((event) => { console.log(event); }); setInterval(() => { try { rb.keyTap('right_alt') } catch (error) { console.log(error) } }, 1000);
it outputs:
{ vKey: 164, rawKey: { _nameRaw: 'VK_LMENU', name: 'LALT', standardName: 'LEFT ALT' }, name: 'LEFT ALT', state: 'DOWN', scanCode: 56, location: [ 0, 0 ], _raw: 'KEYBOARD,DOWN,164,56,0,0,15\r\nKEYBOARD,UP,164,56,0,0,16\r\n' } { vKey: 164, rawKey: { _nameRaw: 'VK_LMENU', name: 'LALT', standardName: 'LEFT ALT' }, name: 'LEFT ALT', state: 'UP', scanCode: 56, location: [ 0, 0 ], _raw: 'KEYBOARD,DOWN,164,56,0,0,15\r\nKEYBOARD,UP,164,56,0,0,16\r\n' }
As can be seen from above, name is 'LEFT ALT' instead of 'RIGHT ALT'
name
'LEFT ALT'
'RIGHT ALT'
If I press right alt key on my keyboard manually, it will show
{ vKey: 165, rawKey: { _nameRaw: 'VK_RMENU', name: 'RALT', standardName: 'RIGHT ALT' }, name: 'RIGHT ALT', state: 'DOWN', scanCode: 56, location: [ 0, 0 ], _raw: 'KEYBOARD,DOWN,165,56,0,0,8084\r\n' } { vKey: 165, rawKey: { _nameRaw: 'VK_RMENU', name: 'RALT', standardName: 'RIGHT ALT' }, name: 'RIGHT ALT', state: 'UP', scanCode: 56, location: [ 0, 0 ], _raw: 'KEYBOARD,UP,165,56,0,0,8085\r\n' }
As can be seen from above, name is 'RIGHT ALT' . This matchs expectations so it should not be the bug of node-global-key-listener.
Then it should be robotjs that sends the wrong alt.
robotjs
The reason I want this bug to be fixed is that I want to set right alt for different usage from left alt. So I need to distinguish the two alt
alt
keyTap('right_alt') actually send left alt instead of right alt
Expected Behavior
keyTap('right_alt')
should send right altCurrent Behavior
keyTap('right_alt')
sends left alt insteadPossible Solution
Steps to Reproduce (for bugs)
I use
node-global-key-listener
to listen to key input.it outputs:
As can be seen from above,
name
is'LEFT ALT'
instead of'RIGHT ALT'
If I press right alt key on my keyboard manually, it will show
As can be seen from above,
name
is'RIGHT ALT'
. This matchs expectations so it should not be the bug ofnode-global-key-listener
.Then it should be
robotjs
that sends the wrong alt.Context
The reason I want this bug to be fixed is that I want to set right alt for different usage from left alt. So I need to distinguish the two
alt
Your Environment