JavaScript From The Start


JavaScript Keyboard Events


Hide/Show description

How to capture and use Keyboard Events with JavaScript. How to determine where the keyboard event is coming from and which key is being used. Not covered in the video is the use of the event properties for determining whether or not the ALT, SHIFT, or CTRL keys were pressed at the same time as the other keys. ev.ctrlKey ev.altKey ev.shiftKey These are the event properties you would use to do that. You can find reference to them through the Keydown reference link below. Code GIST: https://gist.github.com/prof3ssorSt3v3/4e81ae914a37a83492564387f75d3c2e String.fromCharCode ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt Keydown Event Ref: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent