|
|
Thread Tools | Display Modes |
25-03-2011, 04:36 PM | #1 | ||
Join Date: Oct 2004
Location: Opole, Poland
Posts: 14,276
|
Distunguishing regular and keypad Enter keys in C# forms?
I'm working on a C# application that allows a user to configure a control profile for an emulator. Part of that involves binding keyboard keys to controller buttons, and is done through a clickable "on-screen keyboard" dialog. Today, I decided to add keyboard recognition to the dialog window, so that the user can simply press a key on his keyboard to map it.
It's working, apart from the fact that I don't seem to have any way of telling apart the numpad enter key with the regular enter. This is something I need to fix, but can't find any info on how this could be done. The current Code:
[DllImport("user32.dll")] static extern short GetAsyncKeyState(System.Windows.Forms.Keys vKey); private bool IsKeyPressed(Keys key) { if (Convert.ToInt32(GetAsyncKeyState(key).ToString()) == -32767) return true; else return false; } protected override bool ProcessDialogKey(Keys keyData) { if (IsKeyPressed(Keys.LShiftKey)) button55.PerformClick(); else if (IsKeyPressed(Keys.RShiftKey)) button28.PerformClick(); else if (IsKeyPressed(Keys.LMenu)) button69.PerformClick(); else if (IsKeyPressed(Keys.LControlKey)) { if (IsKeyPressed(Keys.RMenu)) button70.PerformClick(); else button67.PerformClick(); } else if (IsKeyPressed(Keys.RControlKey)) button68.PerformClick(); else if (IsKeyPressed(Keys.RMenu)) button70.PerformClick(); else switch (keyData) { case Keys.Escape: button1.PerformClick(); break; // there's 90-something lines of the same thing repeated, differentiated only between different Keys enums and buttons. case Keys.Right: button81.PerformClick(); break; default: break; } return true; } |
||
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
regular | sgtboat | Blah, blah, blah... | 4 | 26-11-2008 03:30 AM |
When will regular updates start? | Doink | Blah, blah, blah... | 6 | 13-12-2007 10:00 AM |
How To Make Html/php Forms Read New Lines? | Danny252 | Programming | 2 | 05-01-2007 08:20 PM |
Enter Thevoid's Gallery | TheVoid | Music, Art, Movies | 672 | 26-06-2006 03:10 PM |
Regular Expressions | Kon-Tiki | Programming | 23 | 26-01-2006 09:58 PM |
|
|
||
  |