You can check the modifier keys provided by the event object. event.shiftKey is for your specific use case. In addition, there are event.altKey , event.ctrlKey and event.metaKey (for Windows keys in windows and a command key in MAC keyboards). In the sample code, you will need to perform a check inside the keyCode handler:
var NUMBER_FIVE = 53; element.onkeydown = function (event) { if (event.keyCode == NUMBER_FIVE) { if (event.shiftKey) {
Also, when using event.keyCode you process what the user pressed on the keyboard. If you want to check for specific ASCII characters, you can use event.charCode because this event property tells you which character the user is event.charCode , instead of telling you that the user is tapping the keyboard. Here is the complete guide for this on quirksmode.
source share