View Full Version : Reading Keypresses without Events?

12-11-2009, 08:22 AM
I am aware of being able to use the key events to find keypresses, but I'm looking for a way to read if any keys on the keyboard have been pressed at the time a function is run.

I am working on a script that is intended to check if the viewer is actively typing anything within the webpage (including iframes, which the normal key events can't reach). Even if they're not typing in a text box, such as using arrow keys to navigate around the page.

I seem to remember a method of using JavaScript to read what the last key pressed was, without needing to use events. Is this possible? If not, is there any way to get the key events to work on an iframe without having to modify the content of the page in the iframe?

12-11-2009, 10:18 PM
My only idea of how to work with this is to use events to store what/when is pushed, then keep that data somewhere (ie, a variable called "lastactivity") and then do whatever you want with it later without needing to (directly) use events.
As for an iframe, I'm really not sure what is possible there.