Global Keyboard Events and AddClassHandler #17432
-
Hi all, My app' is managing global keyboard events using AddClassHandler at the top level, like:
Q1) Is there a better way to handle them, knowing they should be received even when non focused ? Q2) It seems like there is no way to remove this hook when it becomes not needed any longer? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If you own the window, it would be better to handle this event on the window directly with Tunnel strategy. This way, you can avoid static global event handlers, and still handle events first.
This will work for unfocused controls, but focused window. You can't intercept input outside of your app this way. There is no API for that.
It returns a disposable. You can dispose this subscription. |
Beta Was this translation helpful? Give feedback.
If you own the window, it would be better to handle this event on the window directly with Tunnel strategy.
window.AddHandler(InputElement.KeyDownEvent, OnKeyDown, Tunnel, handledEventsToo: true)
(pseudocode).This way, you can avoid static global event handlers, and still handle events first.
This will work for unfocused controls, but focused window. You can't intercept input outside of your app this way. There is no API for that.
It returns a…