How can I add a keyboard shortcut regardless if the focus is on an iframe? - tampermonkey

I run a tampermonkey script adding keyboard shortcuts to a page. With document.addEventListener('keydown', function(e) {} it catches a key stroke well until the focus is on an iframe on this page. Then it stops working.
How can I have the script listen to the keyboard regardless if the focus is on an iframe or not?

Related

What event should be used to handle "clicking" a button in a WPF application on a touchscreen computer?

I am developing a solution that will be used solely on touch computers. Should I use Click, TouchDown, PreviewTouchDown to listen to the event of clicking the button on the touchscreen using touch? Originally I was using Click but I noticed in some cases that the event didnt fire on first finger tap on the touch screen and had to touch it again to fire. I am using .NET 4.8. Thanks!
If you handle the TouchDown and also set the Stylus.IsPressAndHoldEnabled attached property of the Button to false, the event should be raised as soon as the finger touches the screen:
<Button Content="Touch" TouchDown="Button_TouchDown" Stylus.IsPressAndHoldEnabled="False" />
By default and as stated in the docs, the event doesn't occur until a finger touches the screen and moves.

can't click with enter key when nvda is off

I started working with NVDA on a angular JS application to make it more accessible. In the website there are some ng-click activated components (spans/div/articles). When I turn on NVDA screen reader the navigation works fine and I can use the enter key to click on focused element. However when the screen reader is off the navigation with the tab key still works fine, but the enter key does not work anymore. Is there a reason/solution to this?
NVDA and Jaws simulate a mouse click when pressing enter, this is a feature of both screen readers to fight against the general lack of accessibility on most websites.
You need to react to keyboard events yourself if you want your component to activate upon pressing enter for everyone regardless of if they are running a screen reader or not.
However, the best would be to use an element that can be naturally focusable, such as <a> or <button> whenever possible, rather than <span> or <div>.
Elements that are naturally focusable indifferently react on clicks and on enter key without the need to define anything.

Windows universal app - set focus on captureElement

I have simple Win Universal app to capture photos.
When I start my app, I have some screen with button and some informations. When I press the button, I move to another page with captureElement. I wanted to use tap to capture photo and it works. However it doesnt work for first tap on that page. First tap doesnt fire "tapped" event but second and next ones work good. Can I set focus somehow on captureElement? I didnt find it for that type of control

Panningmode on scrollviewer causes wierd focus issue on ShowDialog

I have a WPF application with some content wrapped in a scrollviewer. I also have a custom dialogbox, which basically is a light customized Window I call ShowDialog() upon.
I can use this just fine on both PC and Tablet.
But now I´ve added the PanningMode attribute to the scrollviewer, so the Tablet users can scroll/swipe with their finger, and now the problem occurs: when I use my dialogbox it shows up, but it seems like it doesent have focus. Because the first time I click on a button in the dialogbox, nothing happens. I have to click twice before the button click is registered.
If I remove the panningmode attribute on the scrollviewer, the problem is gone.
This is only a problem on the Tablet, not on the PC.
Any clues?
I found the problem.
I was triggering the dialogbox in mousedown on an image. Tried several events, but the StylusUp did the trick.

Need to capture F12 key and Shift F12 key combination IE8

In the silverlight application if I set Windowless to true on the plugin then F12 key is not captured on KeyUp for the layout root.
I am trying to do this application wide. So I need to capture F12 and SHIFT F12 no matter where the user types it.
Currently I am trying to capture it on the Keyup event of the top level layout root.
This works for IE7, but not IE8
This works for F12 with IE8 windowless = false
This does not work for SHIFT F12 for IE8 windowless=false
This might be a design limitation imposed by Microsoft similar to how you can't capure CTRL-ALT-DEL`.
F12 a shortcut to open the Developer Tools window in IE8. So IE8 probably consumes those key-presses.
The difference in behaviour between window and windowless is that for a windowed (windowless=false) control Windows can send the key message firstly to the that window before any parents (IE in this case) can handle it. So Silverlight can manage it and cancel it before IE has it, whereas with windowless IE is dispatching the key event to the control so can deal with it.
I'm not sure how you can swallow the keypress in Silverlight but in JavaScript you can cancel it using event.returnValue, e.preventDefault() or return false depending which browser you need to support. The below snippet cancels most key presses in IE9 including F12.
document.addEventListener("DOMContentLoaded", function(){
document.addEventListener("keydown", function(e){
window.event.returnValue=false;
e.preventDefault();
return false;
});
});

Resources