捕捉用户键盘击键的文本框 [英] Textbox to capture user's keyboard strokes

查看:80
本文介绍了捕捉用户键盘击键的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在其中一个页面上,我需要添加一个文本框,用户可以在其中输入文本。对于我们来说,重要的是要捕获用户在键入文本时的想法,因此应该捕获诸如退格键,击键之类的笔触。用户单击提交按钮后,管理员应该能够播放操作并查看用户在键入文本时的进度(类似于观看视频)

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 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.

这篇关于捕捉用户键盘击键的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆