rNeomy/reader-view

In chrome, with Dvorak keyboard, Ctrl+L opens the print dialog

Opened this issue · 5 comments

Somehow the extension is ignoring the OS (windows 11) keyboard layout and using the hardware key P. Every other website in chrome CtrlL sets focus to the navigation/search bar. Same happens if I type CtrlO and it treats it as CtrlS instead.

This appears to be the use of KeyboardEvent.code (the physical key pressed) rather than KeybordEvent.key (the character typed) in the keydown event listener in index.js, but it seems the key codes with the 'Key' prefix are used through the settings so it's not just a matter of changing the property being accessed, as you'd get 'p' rather than 'KeyP' when P window.addEventListener('keydown', e => { console.log('code', e.code); console.log('key', e.key); }) gives


code ControlLeft 
key Control
code KeyP
key l

for the Ctrl+L sequence on my keyboard. Replacing 'e.code' with 'Key'+e.key.toUpperCase() should do it.

Thanks for the report. Can you confirm the fix on the latest commit?

We have a problem; https://add0n.com/chrome-reader-view.html#IDComment1117191678

Today my hotkeys set to arrows stopped working, and hotkeys set to letters only work if the keyboard language is set to English. Why?

I'm still looking at how we could do this; so far the hotkey libraries I've looked at also fail if the keyboard layout changes.

An alternative would be to use CSS media to remove the toolbar when printing, and not have to process the ctrl-P shortcut at all in the extension. Currently on a Dvorak keyboard, Ctrl-P opens the print dialog in chrome, Ctrl-L opens the print dialog through the extension and shows the same content but without the toolbar.