reader-view icon indicating copy to clipboard operation
reader-view copied to clipboard

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

Open pete-kirkham opened this issue 3 years ago • 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.

pete-kirkham avatar Oct 03 '22 17:10 pete-kirkham

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.

pete-kirkham avatar Oct 03 '22 17:10 pete-kirkham

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

rNeomy avatar Oct 24 '22 08:10 rNeomy

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?

rNeomy avatar Oct 29 '22 05:10 rNeomy

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.

pete-kirkham avatar Nov 02 '22 11:11 pete-kirkham

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.

pete-kirkham avatar Nov 02 '22 12:11 pete-kirkham