tags:

views:

82

answers:

1

I'm using the following code to decide if a '.' (full stop) has been entered into a webbrowser control:

    private void body_KeyUp(object sender, HtmlElementEventArgs e)
    {
        if (e.KeyPressedCode == '.')
        {
            // Do something
        }
    }

According to msdn KeyPressedCode returns an ASCII value. What I get by breakpointing is '190' if I enter a '.' however. This is not even listed in the standard ASCII table. Obviously I could simply test for 190 but I fear that KeyPressedCode might return different values on different systems with different code pages, languages and so on.

So can you please explain me why KeyPressedCode returns '190' instead of '46' and how I can manage this problem 'safely'?

Interestingly enough the return value for ' ' (space) is always correct ('32'). Playing with System.Text.Encoding.GetEncoding and different code pages didn't solve the problem, I don't have much experience with code pages however.

A: 

Just a wild guess, but have you checked the values of e.AltKeyPressed , e.CtrlKeyPressed and e.ShiftKeyPressed ? Hope you see what I'm getting at...

Dan Diplo