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

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

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

相关文章:

  • 2021-08-11
  • 2021-12-09
  • 2022-03-01
  • 2022-02-03
  • 2021-11-25
  • 2021-05-24
  • 2021-11-17
猜你喜欢
  • 2021-11-29
  • 2021-08-21
  • 2021-07-13
  • 2022-01-07
  • 2022-01-04
  • 2021-12-05
  • 2022-01-14
相关资源
相似解决方案