标签:
今天买了个二手机械键盘,自己写了个键盘测试工具。
不是很精致,无需安装,简单实用。
WPF项目 附代码:
public MainWindow() { this.InitializeComponent(); EventManager.RegisterClassHandler(typeof(Window), Keyboard.KeyUpEvent, new KeyEventHandler(Soc_KeyDown), true); } private void Clear_Click(object sender, RoutedEventArgs e) { txb_history.Text = ""; txt_thiskey.Text = ""; } private void Soc_KeyDown(object sender, KeyEventArgs e) { Key k = e.Key; string Ks = k.ToString(); if (k == Key.System) { Ks = "F10"; } txt_thiskey.Text = Ks; string history = ""; if (txb_history.Text != "") { history = txb_history.Text + ","; } history += Ks; List<String> KeyList = history.Split(‘,‘).ToList(); if (KeyList.Count > 10) { KeyList.RemoveAt(0); } history = ""; foreach (var key in KeyList) { history += key + ","; } history = history.Substring(0, history.Length - 1); txb_history.Text = history; }
百度网盘:http://pan.baidu.com/s/1dDzVuIt
标签:
原文地址:http://www.cnblogs.com/fb208/p/4188344.html