捕捉用户键盘击键的文本框 [英] Textbox to capture user's keyboard strokes
问题描述
在其中一个页面上,我需要添加一个文本框,用户可以在其中输入文本。对于我们来说,重要的是要捕获用户在键入文本时的想法,因此应该捕获诸如退格键,击键之类的笔触。用户单击提交按钮后,管理员应该能够播放操作并查看用户在键入文本时的进度(类似于观看视频)
On one of the pages, there is a need for me to add a 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)
asp.net mvc或webforms的实现方式是什么?
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捕获所有KeyUp或KeyDown事件。 KeyPress,KeyDown,KeyUp之间的差异。
- 将每个击键记录到
< input type ='hidden'/>
或< asp:Hidden>
。使用 JavaScript密钥代码(这是另一个浏览器之间的JavaScript有所不同的)。该文章的底部有大量示例。使用自己的分隔符将每个keyCode附加到该值。当用户完成操作并回发时,您将得到34 | 73 | 91 | 13 |
- 隐藏字段的值。您将拥有一串KeyCode来回放在该文本框中捕获的击键。
- 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 with34|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.
这篇关于捕捉用户键盘击键的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!