Add common keyboard controls
A few issues have been asking for this, and the other PR is incomplete, so I thought I would just do it.
The new keybinds are:
- Up/Down for volume controls
- +/- for player speed (and -/= so you dont need to hold shift)
- the bracket keys [] and {} to skip ahead in chapters, along with Page Up and Down,
The left/right arrow key controls have been moved so focusing on the main page should work to seek. As a side effect of that is the skip/rewind buttons in the playerbar are slightly more responsive
The search page cant type the brackets or plus minus keys without the current keybinds overriding them, but I'm looking for a fix to that now
EDIT: Search works as expected now
It should probably be put on the DEVELOPMENT.md that this project is linted with ruff, didnt realize that until it errored for the first time
Thanks for working on this :)
There are a couple of issues with the current implementation as I see it. The first is actually an accessibility issue. Since common keys normally used for keyboard are all bound to a playback control action (except Tab), it's quite hard to navigate the Cozy's UI using the keyboard. This is due to the fact that all shortcuts are bound on the application object, thus they are also active in the preferences window for example. I think since these are not actual key combinations, only hotkeys, they shouldn't be bound on the application level, instead on the main navigation view widget.
My other issue is that due to how the create_action is implemented on the CozyUI class, that same class needs to have all the callback methods, even though they belong to other widgets. I think this issue would be solved though, if those actions were bound on the navigation view class.
Since common keys normally used for keyboard are all bound to a playback control action (except Tab), it's quite hard to navigate the Cozy's UI using the keyboard.
It was very inconsistent otherwise, so I left them overridden on the main view, but disable these shortcuts in dialogs.
Now about the actual keyboard shortcuts: As multiple people mentioned in the issues already, VLC is a good example to follow here, so for example, I would use "=" to reset the speed instead of increasing it. I'd also like to drop shortcuts that are awkward to use with non-English keyboards, like the bracket (AltGr+F for me for example), and instead add Ctrl+arrows for those who don't have Page Up and Down keys. It's also a good idea to use the keypad buttons, as they are sometimes more accessible. Here is what I think would work:
- +/- to increase/decrease playback speed (along with the ones on the keypad)
- = to reset speed
- PgUp/PgDown and Ctrl+Left/Right for skipping chapters
In the future I would also explore adding more modifiers to the arrow keys for forward/rewind (Shift+arrow, Alt+arrow), as I think that would be more useful than being able to set a custom interval in the preferences.
I agree with most of the changes made, although I dont think its a good idea to copy VLCs playback speed behavior. As it is now, you need to hold shift to increase the speed, but cant when decreasing it, which makes it frustrating to adjust it, Keeping the controlls +/= -/_ makes it far less annoying to use those hotkeys.
I agree that a speed_reset button is a good idea, maybe it could be moved to the 0 key?
The keyboard behavior in the rest of the app is very inconsistent and definitely needs some more work though.
I see your point, however, I'd prefer assigning these shortcuts based on semantics, and not on convenience of access.
An annoying shortcut is usually relative. For example, take a look at the German keyboard layout, where neither - and + requires shift:
The other example is my keyboard, where the - is down on the bottom, + is Shift+3, = is Shift+7, and zero is on the other end of the keyboard. Let me tell you, it's it's quite annoying to use any keyboard shortcuts on this layout.
I'll do some more research to see, how other apps do this, but I'd like to avoid adding shortcuts, that are convenient to use on English, and similar keyboards, but doesn't make sense, and/or are inconvenient on any other layout.
We could assign < and > in addition. How do you feel about that?
How about Shift or Cntrl +Up and Down? The up/down arrow keys are only used for volume now, and they dont move on most keyboard layouts (I hope). Changing the speed doesn't happen often enough that the modifier key is a problem, and atleast its consistent.
Thanks, @Haaruun-I!