Keyboard shortcuts in webview applications
See original GitHub issueHello,
we are migrating to NWjs v0.30.x . We have noticed difference from 0.27.x in keyboard events in combination with webview.
We have keyboard shortcuts in our application that were relying on keydown
event, like
window.addEventListener("keydown", (evt) => {
if (evt.ctrlKey) {
switch (evt.key) {
case "q": return nw.App.quit();
case "n": return nw.Window.create(location.href);
// etc...
}
}
});
But this has stopped to work, because the parent frame doesn’t receive the keydown
event when webview is focused.
(IM)POSSIBLE WORKAROUNDS
nw.Window.get().menu = new nw.Menu() ...
- but we have undecorated window and thus this is unusable on Windows and Linux- We would require to be able to hide visual representation of the menu (maybe the
Alt
key to show it)
- We would require to be able to hide visual representation of the menu (maybe the
nw.Shortcut
- but it is system-wide and unregistereing them based on focus is somewhat unreliable- We would require to be able to register shortcut just for the application, not system-wide
chrome.commands
- the shortcut must start with a special key (likeCtrl
,Alt
, …), so shortcuts likeF5
for reloading the webview are impossible- We would require to be able to register shortcut with any key combination, including a single key like
Esc
,F5
, …
- We would require to be able to register shortcut with any key combination, including a single key like
Any suggestions?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:15 (5 by maintainers)
Top Results From Across the Web
Screen reader keyboard shortcuts for mobile apps on Windows
Keyboard shortcuts ; Navigate to the previous character. Alt + Shift + Left arrow ; Select the focused element. Alt + Enter ;...
Read more >Manage shortcuts | Android Developers
Your app tracks usage for dynamic shortcuts by calling the pushDynamicShortcut() method and passing it the ID of the shortcut when a relevant ......
Read more >Listen Webview Key Events from software keyboard in ...
Is it possible to handle software keyboard events from a webview in a host Android application? For example, can my application's Activity ...
Read more >WebView2: Forwarding Alt Keys to a Host WPF Window
With focus in the WebView, if you now press the alt key at that or any alt key combination, you'll find out that...
Read more >Windows Subsystem for Android Keyboard Shortcuts for ...
Keyboard Shortcuts for in-app Navigation ; Navigate to the item below, Alt + Down arrow ; Navigate to the first item, Alt +...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As others have mentioned this issue is critical for those implementing anything touching
webview
elements…And unfortunately the proposed workaround of injecting JS into the
webview
and using messages is not quite “safe”, especially sincewebview
elements are used to contain untrusted sources…(Moreover given that for many releases this feature worked, and now it suddenly doesn’t isn’t very reassuring for the reliability and stability of the platform…)
Is there some documentation on how to use at least the
chrome.commands
feature innw.js
?Can anyone just guide me (just in short): i have a concept which could be build using nw.js. I have worked longer time ago with electron.
I want to have a parent window, which embeds a webview just as a child, to view it like a movie. The webview should be safe, but it’s just like a gimmick. The parent - the master - the worker - that’s the parent, so every shortcut must be handled by the parent, not the webview.
What’s the way right now?