In the spirit of iOSDesignExtensions and AndroidDesignExtensions, I’m starting a new XojoWebExtensions Github repo for free extensions & controls for the Web 2.0 framework.
The first control in this collection is called KeyInterceptor and is designed to allow you to catch more than just CMD/CTRL keys that the user might press. With this class, you can capture a lot of different key combinations with modifiers like:
- CMD/CTRL (the Meta key)
- SHIFT
- ALT/OPTION
- CTRL (different than meta on macOS)
As well as plain old keys like F5, Escape, Enter and TAB (understanding that some of these keys are used by the web framework itself and may cause a conflict).
At the moment, the code is written so that it intercepts the key, preventing the browser from handling it (where possible), but some browsers don’t allow that for every key. For instance, Safari doesn’t allow intercepting CMD-R (refresh) on macOS whereas it works perfectly fine on Firefox.