1
Vote

where is KeyEventArgsExt!?

description

Hi,
I'd like to get the exact key's character on a key press event. Currently I can get the key's position (= constructer's code) but not the char.
I'd like for example to get the char "[" when I press it. All I can get is "oem1".
From what I understood, I should be able to use KeyEventArgsExt from the event KeyDown of KeyboardHookListener.

Here's my code:
KeyboardHookListener k_keyboardListener = new KeyboardHookListener(new GlobalHooker());
k_keyboardListener.Enabled = true;
k_keyboardListener.KeyDown += k_keyboardListener_KeyboardDown;
k_keyboardListener has no method KeyDownExt. And the only argument k_keyboardListener_KeyboardDown would allow is "System.Windows.Forms.KeyEventArgs e" but I would like "MouseKeyboardActivityMonitor.KeyEventArgsExt e"

What I get:
private void k_keyboardListener_KeyboardDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
//TODO: ...
}
What I want:
private void k_keyboardListener_KeyboardDown(object sender, MouseKeyboardActivityMonitor.KeyEventArgsExt e)
{
//TODO: ...
}
Am I missing something or KeyEventArgsExt is just deactivated?
sincerely,
zougi

EDIT: I found a dirty workaround casting KeyEventArgs as KeyEventArgsExt. Why KeyEventArgsExt is not able by default? Maybe you could document it!?
MouseKeyboardActivityMonitor.KeyEventArgsExt ee = e as MouseKeyboardActivityMonitor.KeyEventArgsExt;
Console.WriteLine(ee.UnicodeChar);

comments

zougi wrote Sep 7, 2014 at 7:09 PM

Note: I'm using V4 alpha 2. on a visual studio 2012 project.

zougi wrote Sep 7, 2014 at 7:26 PM

"[" wasn't the best example because :
e.KeyData gives OemOpenBrackets when I press this key which I can understand
but the worst is when I press "!" on my qwerty:
I get: D1, Shift
:/

wrote Sep 7, 2014 at 7:31 PM

wrote Sep 7, 2014 at 7:31 PM

wrote Sep 7, 2014 at 7:41 PM

wrote Sep 7, 2014 at 8:10 PM

wrote Sep 7, 2014 at 8:10 PM