views:

46

answers:

2

I need to be able to record keyboard events on elements that act like password (masked) inputs.

It sounds sinister, but I assure you it's not. I am not a phisher or scam artist of any kind. My users will be made aware that there behaviour is being analysed and are instructed not to enter a password that they use anywhere else.

With that out of the way, does anyone know of a way to capture keyboard on a password field? The default behaviour is that no keypress, keyup or keydown events are fired when a password input has focus. (At least in Chrome, but even this is unacceptable for us.)

The only way I can think to do it would be to use an invisible input laid over a password field? But I'm not even sure how I'd do this.

All suggestions welcomed.

+2  A: 

Where did you get the idea that Chrome doesn't fire key events on input boxes with type="password"? I would suggest that there's a problem with the code you've tried.

Here's an example: http://jsfiddle.net/UnL8q/ - Albeit using jQuery, but jQuery just maps to the DOM events anyway.

Andy E
Figured it out. Thanks for the (well needed) slap of reality!
Tom Wright