.net |
中最简单的方法是捕获Keyboard.KeyDown事件。
我正在.Net 4.0 C#中开发一个Windows控制台应用程序,用于分析键入模式。
我添加了“ 0”引用来访问“ 1”对象。
我要强调的是,我不仅要捕获按下的键,还需要计算按下键的时间。这就是为什么我需要访问
KeyDown
和KeyUp
事件。
如何实现KeyDown
和KeyUp
事件处理程序?
KeyDown
事件应仅从应用程序的上下文记录。
这是我尝试过的代码:(请注意,我被困在分配处理程序上)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
namespace TypingBiometrics
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(\"Type this sentence\");
Console.ReadLine();
Keyboard.KeyDownEvent += new KeyboardEventHandler(/*not sure here*/);
}
public void KeyDown(Object sender, KeyboardEventArgs e)
{
Console.WriteLine(e.ToString());
}
}
}
没有找到相关结果
已邀请:
2 个回复
梦砍废么
凰葱崎济邯
就足够了。但是,您将需要将该功能标记为静态。