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

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 previewkeydown 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.

Upvotes: 2

Views: 1053

Answers (1)

anivas
anivas

Reputation: 6547

(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.

Upvotes: 4

Related Questions