Concat KeyDown event (Keys) to one C# (wpf) string

怎甘沉沦 提交于 2019-12-04 06:48:25

Ok I am making a number of assumptions here:

  1. The value is typed into a text box.
  2. The card reader uses the enter key when it has entered all the values.

If the above is true, you can do this:

private void OnKeyDownHandler(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Return)
    {
        var valueEntered = cardReaderValue.Text;
    }
}

Try casting it:

char c = (char)e.KeyCode;
string keylog=""; // do global declaration
//use the bellow line in event handler
keylog= keylog +  e.Key.ToString();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!