Welcome Guest Search | Active Topics | Sign In | Register

Some keys are not firing in KeyUp Options
Christian Porzio
Posted: Monday, August 28, 2017 4:10:43 PM
Rank: Advanced Member
Groups: Member

Joined: 10/4/2016
Posts: 104
Hi,

To begin with I was wondering if anything new took place since: https://www.essentialobjects.com/forum/postst9519_KeyUp-event-not-firing.aspx

If nothing new, I would almost be good the way it is but that handler does not make the difference between left Ctrl and Right ctrl, in both case I receive the same event while other WPF or Form .Net Key handlers are able to make the difference.

Additionally I am not receiving anything when pressing left ALT or right ALT keys?

Thank you for you assistance.
eo_support
Posted: Tuesday, August 29, 2017 2:36:53 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,225
Hi,

KeyUp event indeed has been added since that post. Both the KeyDown event and KeyUp event are on the WebView class. If you handle those two events directly, you should be able to intercepts most keyboard events --- with one significant exception is VK_MENU (when Alt is down). These two keys are NOT forwarded to the .NET side because it can cause conflicts with the system menu keys. However you should be able to distinguish left ctrl/right ctrl from these events. Note that the event arguments for these two events are raw windows message values. For key down, the corresponding window message is WM_KEYDOWN, for key it is WM_KEYUP. You can then look for MSDN reference for these two messages to interprets WPARAM and LPARAM.

Hope this helps. Please feel free to let us know if you still have any questions.

Thanks!
Christian Porzio
Posted: Tuesday, August 29, 2017 3:06:07 PM
Rank: Advanced Member
Groups: Member

Joined: 10/4/2016
Posts: 104
Thank you for your quick response and sorry I meant to update my own post because indeed using
Code: C#
void WebView_KeyDown(object sender, WndMsgEventArgs e)
and its equivalent KeyUp, one can receive all key stroke events, even the ALT combinations, just that they are not sent on VM_KEY and only received by KeyDown.

However my main concern is that I have already a number of .NET methods that were using a
Code: C#
KeyEventArgs
input message.

And translating the raw Window message into such an advanced .Net object is not easy work. I researched a little bit but did not find anything conclusive with that respect.

Additionally unlike with the .Net key stroke handlers, it is not possible to block the keystroke at the application level by using an attribute such as handled=true

Regards
eo_support
Posted: Wednesday, August 30, 2017 3:46:50 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,225
Hi,

There is no direct KeyEventArgs translation, however you can "borrow" a .NET control to do the translation for you by calling Windows API PostMessage to post the raw messages to that control's window handle. You would then handle .NET's standard KeyDown/KeyUp event on that control.

There is no way for you to cancel a keyboard event like you do with standard .NET event. When a keyboard event occurs inside the browser engine, it is immediately processed by the browser engine following it's own event handling mechanism. These key events at the same time, are forwarded to the .NET side so that your code will have a chance to examine it, but since the browser engine does not wait for the .NET side to return, there is no way for the .NET side to cancel it.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.