开发者

In WPF , how to find out if a pressed key is a input key or not (one which prints something or not )?

开发者 https://www.devze.com 2023-03-17 14:20 出处:网络
I am having some requirement in which I have to find out if the key pressed is a input key. I have a TextBox with a previewke开发者_StackOverflowydown event.

I am having some requirement in which I have to find out if the key pressed is a input key.

I have a TextBox with a previewke开发者_StackOverflowydown event.

 <TextBox PreviewKeyDown="MyTextBox_PreviewKeyDown" ></TextBox>

Then I have the code for event handler here

    private void MyTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
    {
        //I need to find out here if key pressed is 
        // an input key something like
        // if ( key is between a to z or 0 to 9 or some_character_input)
        // {
        //
        // }   
        //else 
        //{
        //     Key is either F1,F2,UpArrow, DownArrow, etc
        // }
    }

Please guide me how to go about with it.


(int)e.Key between 44 and 69 are alphabets. Between 90 and 113 are function keys. Decompile System.Windows.Input.Key enum in reflector or dotpeek you will get values for all keys.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号