开发者

Textbox to capture user's keyboard strokes

On one of the pages, there is a need for me to add a开发者_StackOverflow社区 textbox in which the user types in text. It is important for us to capture what the user is thinking while he's typing in the text, so strokes such as backspace, keys should be captured. Once the user clicks on the submit button, the administrator should be able to 'play' the actions and review how the user progressed while he was typing in the text (similar to watching a video)

What would be the asp.net mvc or webforms way of doing this?


Consider another non-control approach, or wrap this into your new control.

  • JavaScript capturing all KeyUp or KeyDown events. Difference between KeyPress, KeyDown, KeyUp.
  • logging each keystroke to an <input type='hidden' /> or <asp:Hidden>. Use the JavaScript KeyCode (here's another with some differences in JavaScript between browsers). There's a great sample at the bottom of that article. Append each keyCode to the value with your own separator. You'll end up with 34|73|91|13|
  • when the user is done, and you postback, find the value of the hidden field. You'll have a string of KeyCodes playing back the keystrokes that were captured in that textbox.


I do not know if there is a custom control which already does this, in general I think you could implement your need in this way: save all key press with ClientSide OnKeyPress event, put all the key codes in a list, when user clicks submit pass this list to the server side code then you can simply re-apply all those changes in the same order, this is the video you wanted to play :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜