Forum Moderators: open
I also need to capture when a user presses the ShiftKey WITH an F-Key. This allows for up to 24 F-Keys with mainframe applications.
I found the information for the window.event routine to capture when I press the ShiftKey, but still haven't found the right combination to capture when a key is pressed and held.
Does anyone know that bit of code?
Thanks.
All I've learned is that there is a way to tell when there is a keyup event while another key is still held, which sounds like a hopeful direction. But the keycode particulars, etc. weren't to be found.
So, this is really a "bump", not an answer.
Just can't find it. I've seen it action, but couldn't get to the script to "learn" how it was done.
That's the way I'd proceed.
Maybe I'll whip together a test page later today.
Put the checkeydown() sample function below in a script tag and add the onkeydown event to the body tag as below. When you hold down shift and press F4, the alert will pop up showing the function has fired.
Note: For keys like F4 (115) which are functional within IE (F4 drops down the addressbar), make sure you've got the event.returnValue = false statement included like the example.
function checkeydown() {
if (event.shiftKey && event.keyCode == 115) {
event.returnValue = false;
alert('Shift + F4 Pressed')
}
}
<body onkeydown="checkeydown();">
txbaker wrote:
"Thanks Blob, but you're supposition is right, once a key is pressed the event is lost, so we couldn't check for both."
This is only half-right. yes the event only fires once. But the event is a javascript object and objects can have properties and shiftKey is a property of the event object.
It answers the question: what was the state of the shift key when that event fired?