I want to modify the behavior of a Button, depending on whether the shift or alt key is pressed while the button was Clicked.
I tried to check the MouseEvents shiftKey property but the event that gets passed to the OnClick function looks something like this, so shiftKey property is undefined
{
"bubbles": true,
"cancelable": true,
"defaultPrevented": false,
"eventPhase": 3,
"isTrusted": true,
"target": {
"id": "",
"tagName": "SPAN"
},
"timeStamp": 1224183,
"type": "click"
}
Definition of onClick function
<Button appearance='primary' onClick={(e)=>{console.log(e)}}>Debug</Button>
I also tried to add a Event listener, to keep track of whether the shift key is pressed in my code, but any EventListener I try to add never gets called .
window.addEventListener('keydown', ()=>{console.log('test')})
Any Idea what I could be doing wrong, or another approach that could work, would be appreciated.