码迷,mamicode.com
首页 > 其他好文 > 详细

键盘测试工具

时间:2014-12-27 15:03:18      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:

今天买了个二手机械键盘,自己写了个键盘测试工具。

不是很精致,无需安装,简单实用。

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!