Tag: keybord

  • How to get keydown event in JavaScript

    The Sample code Break down the sample code 1. document.addEventListener(‘keydown’, event => { … }); 2. if (event.ctrlKey && event.code === ‘KeyB’) { … } 3. event.preventDefault(); KeybordEvent class properties Property Type Description Example ctrlKey boolean Whether the Ctrl key is pressed true / false shiftKey boolean Whether the Shift key is pressed true /…