I am writing a simple function in jQuery. When I hit the 1 key on my keyboard it hides my documents. This works fine:
document.onkeypress=key1;
function key1(e) {
if (e.which == 49) {
// alert("testing");
$("#documentViewer").hide();
}
}
Now the problem occurs when instead of pressing 1, I want this function to work on print screen (keycode 44
) or Windows key (keycode 91
/92
) when I pressed them.
I tried including changing the keycode to these values and sadly, it doesn't hide the document or even throw an alert
call. It couldn't detect the key press.
I even used this link below to check what is the keycode when I pressed a key: https://keycode.info/
Pressing printscreen or win keys does not give me any value at all. I do not know why. Is there anything I am doing wrong?