开发者

How could I emulate an HTML password field (but one which fires keydown events)?

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.


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.


password strength indicators do this.

Some examples:

  • http://simplythebest.net/scripts/ajax/ajax_password_strength.html
  • http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/PasswordStrength/PasswordStrength.aspx
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜