-
Notifications
You must be signed in to change notification settings - Fork 983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyboard shortcut modal #6306
Keyboard shortcut modal #6306
Conversation
…at/keyboard-shortcut-modal
…c icons, capitalize non-special shortcut letters
CTRL+Z is the standard keyboard shortcut for undo on Windows. We should probably use the same shortcut that YouTube does. |
src/renderer/components/FtKeyboardShortcutPrompt/FtKeyboardShortcutPrompt.vue
Outdated
Show resolved
Hide resolved
src/renderer/components/FtKeyboardShortcutPrompt/FtKeyboardShortcutPrompt.vue
Outdated
Show resolved
Hide resolved
src/renderer/components/FtKeyboardShortcutPrompt/FtKeyboardShortcutPrompt.vue
Outdated
Show resolved
Hide resolved
<ft-button | ||
:label="$t('Settings.Show Keyboard Shortcuts')" | ||
@click="showKeyboardShortcutPrompt" | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your screenshot the button looks very out of place in its current position, but I can't think of anything better at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair call out, I didn't know what exactly to do with this one either. This was another adjustment I tried out. Open to this one or any other suggestions. @absidue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it could be under general setting with a keyboard icon added to the button? Or maybe a separate keyboard shortcuts "settings section" (so it wouldnt be using a modal popup and would just display all the shortcuts under the Keyboard Shortcuts section but we'd be able to update it to support #251 eventually).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's its own setting section, I do worry that people will think it's already modifiable. I can put it on its own row there as a button for now if that works, but it might still look out of place and not fit in as a "general setting".
Edit: I do love the keyboard icon idea and incorporated that now. Still unsure on how best to improve the placement.
Co-authored-by: absidue <[email protected]>
Change shortcut to be more accurate, remove duplicate action for closing current FreeTube window, update label for force reload
…reeTube into feat/keyboard-shortcut-modal
5469153
to
8476c4a
Compare
|
Conflicts have been resolved. A maintainer will review the pull request shortly. |
Weird suggestion: If a contributor adds a shortcut key than they also have to :
Would it be possible to generate the contents of the shortcut modal based on the docs? That way if someone changes something in the docs it will automatically be reflected within the app. Pull latest list on startup just like the IV instances. |
@PikachuEXE just tested is and it looks pretty good. Unsure if this is really needed |
I don't think we should do that. Invidious instance list is from a public api that we dont control and can be updated without a new version of FreeTube being installed. If we get the modal from the docs repo then either the modal will be incorrect for nightlies or will be incorrect for the release. Another option is we could update the docs repo's keyboard shortcuts section to mention that you can now view the keyboard shortcuts in the app, show how to view the shortcuts and mention how that page might be out of date. |
That's an interesting idea. The two main approaches I can think of would be parsing the HTML directly (which might have different formatting, preambles, etc. than we would prefer for an in-app modal) or getting it from a JSON file of shortcuts (like we do with the Invidious instances). The main issue with the latter is that we'd have to either update the JSON file as well for each change (thus being the same amount of effort of two changes per new/modified shortcut) or convert the docs page to grabbing the data dynamically from the JSON file as well, which would be shaky and might be hard to section & format. So I don't think there's a solution at the moment that would guarantee a lower amount of net effort. Edit: Whoops, just updated to see a similar comment by @ChunkyProgrammer. |
Should code comments be added to the shortcuts section so people are aware they also have to change it in the modal when they are adding/changing shortcuts? |
The latest code comment doesn't seem to mention the modal |
00eff2a
to
31349ab
Compare
31349ab
to
0126970
Compare
Implemented #5966 but it depends on this |
src/renderer/components/FtKeyboardShortcutPrompt/FtKeyboardShortcutPrompt.vue
Outdated
Show resolved
Hide resolved
.shortcut { | ||
font-family: monospace; | ||
display: table-cell; | ||
vertical-align: middle; | ||
text-transform: capitalize; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking: We should probably use the <kbd>
HTML tag to inform the browser that they are keyboard keys, instead of setting it to monospace with CSS. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/kbd
The reason I am tagging this as non-blocking is that it would require changes to the way we convert the keyboard shortcuts in getLocalizedShortcut
as each key would need to be wrapped with that HTML tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree with this point in the abstract, although for this particular element type, the benefit is quite small.
['SHOW_SHORTCUTS', t('KeyboardShortcutPrompt.Show Keyboard Shortcuts')], | ||
['HISTORY_BACKWARD', t('KeyboardShortcutPrompt.History Backward')], | ||
['HISTORY_FORWARD', t('KeyboardShortcutPrompt.History Forward')], | ||
['FULLSCREEN', t('KeyboardShortcutPrompt.Fullscreen')], | ||
['NAVIGATE_TO_SETTINGS', t('KeyboardShortcutPrompt.Navigate to Settings')], | ||
( | ||
isMac | ||
? ['NAVIGATE_TO_HISTORY_MAC', t('KeyboardShortcutPrompt.Navigate to History')] | ||
: ['NAVIGATE_TO_HISTORY', t('KeyboardShortcutPrompt.Navigate to History')] | ||
), | ||
['NEW_WINDOW', t('KeyboardShortcutPrompt.New Window')], | ||
['MINIMIZE_WINDOW', t('KeyboardShortcutPrompt.Minimize Window')], | ||
['CLOSE_WINDOW', t('KeyboardShortcutPrompt.Close Window')], | ||
['RESTART_WINDOW', t('KeyboardShortcutPrompt.Restart Window')], | ||
['FORCE_RESTART_WINDOW', t('KeyboardShortcutPrompt.Force Restart Window')], | ||
['TOGGLE_DEVTOOLS', t('KeyboardShortcutPrompt.Toggle Developer Tools')], | ||
['RESET_ZOOM', t('KeyboardShortcutPrompt.Reset Zoom')], | ||
['ZOOM_IN', t('KeyboardShortcutPrompt.Zoom In')], | ||
['ZOOM_OUT', t('KeyboardShortcutPrompt.Zoom Out')], | ||
['FOCUS_SEARCH', t('KeyboardShortcutPrompt.Focus Search')], | ||
['SEARCH_IN_NEW_WINDOW', t('KeyboardShortcutPrompt.Search in New Window')], | ||
|
||
['REFRESH', t('KeyboardShortcutPrompt.Refresh')], | ||
['FOCUS_SECONDARY_SEARCH', t('KeyboardShortcutPrompt.Focus Secondary Search')], | ||
|
||
['CAPTIONS', t('KeyboardShortcutPrompt.Captions')], | ||
['THEATRE_MODE', t('KeyboardShortcutPrompt.Theatre Mode')], | ||
['FULLSCREEN', t('KeyboardShortcutPrompt.Fullscreen')], | ||
['FULLWINDOW', t('KeyboardShortcutPrompt.Full Window')], | ||
['PICTURE_IN_PICTURE', t('KeyboardShortcutPrompt.Picture in Picture')], | ||
['MUTE', t('KeyboardShortcutPrompt.Mute')], | ||
['VOLUME_UP', t('KeyboardShortcutPrompt.Volume Up')], | ||
['VOLUME_DOWN', t('KeyboardShortcutPrompt.Volume Down')], | ||
['TAKE_SCREENSHOT', t('KeyboardShortcutPrompt.Take Screenshot')], | ||
['STATS', t('KeyboardShortcutPrompt.Stats')], | ||
|
||
['PLAY', t('KeyboardShortcutPrompt.Play')], | ||
['LARGE_REWIND', t('KeyboardShortcutPrompt.Large Rewind')], | ||
['LARGE_FAST_FORWARD', t('KeyboardShortcutPrompt.Large Fast Forward')], | ||
['SMALL_REWIND', t('KeyboardShortcutPrompt.Small Rewind')], | ||
['SMALL_FAST_FORWARD', t('KeyboardShortcutPrompt.Small Fast Forward')], | ||
['DECREASE_VIDEO_SPEED', t('KeyboardShortcutPrompt.Decrease Video Speed')], | ||
['INCREASE_VIDEO_SPEED', t('KeyboardShortcutPrompt.Increase Video Speed')], | ||
['SKIP_N_TENTHS', t('KeyboardShortcutPrompt.Skip by Tenths')], | ||
['LAST_CHAPTER', t('KeyboardShortcutPrompt.Last Chapter')], | ||
['NEXT_CHAPTER', t('KeyboardShortcutPrompt.Next Chapter')], | ||
['LAST_FRAME', t('KeyboardShortcutPrompt.Last Frame')], | ||
['NEXT_FRAME', t('KeyboardShortcutPrompt.Next Frame')], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to future self: Look into if there is a way to do this, without having to having to use strings as the keys, to reduce the bundle size (also forces terser to bail-out of most optimisations on the KeyboardShortcuts
constant e.g. mangling the names and hoisting them out of the object). Currently this pull request adds about 7921 bytes to the bundle size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a note, this representation might change a bit if we implement #251, but I imagine we'll keep the keys around. I don't have any intention on implementing it currently, but my thought would be we have each action has a unique name, each action+name is mapped to a unique shortcut combo, and we replace a lot of our keydown logic with a combo-reading util function that accepts a list of accepted names as arguments. The localization key in that case could either come from putting the name through a de-snake-case-ifier or as another property on the constant object.
2e36a7c
* Add keyboard shortcut modal * Temp * Add keyboard shortcut modal shortcut entry, shift & enter labels + Mac icons, capitalize non-special shortcut letters * Use usei18n instead of i18n.t * Improve keyboard shortcut button formatting * Update prompt logic to focus ft-icon-buttons as well * Improve mobile styling * Adjust v-for key to reflect new template structure * Apply suggestions from code review Co-authored-by: absidue <[email protected]> * Implement review suggestions Change shortcut to be more accurate, remove duplicate action for closing current FreeTube window, update label for force reload * Change shortcut to YouTube's SHIFT+? * Use keyboard icon for button, and check for usingElectron in showing it * Change ctrl+R shortcuts to use new labelling * Exit FS and/or FW when keyboard shortcut modal is opened * Add code comment clarifying where parallel change to shortcut documentation should be * Implement changes from review --------- Co-authored-by: absidue <[email protected]>
* Add keyboard shortcut modal * Temp * Add keyboard shortcut modal shortcut entry, shift & enter labels + Mac icons, capitalize non-special shortcut letters * Use usei18n instead of i18n.t * Improve keyboard shortcut button formatting * Update prompt logic to focus ft-icon-buttons as well * Improve mobile styling * Adjust v-for key to reflect new template structure * Apply suggestions from code review Co-authored-by: absidue <[email protected]> * Implement review suggestions Change shortcut to be more accurate, remove duplicate action for closing current FreeTube window, update label for force reload * Change shortcut to YouTube's SHIFT+? * Use keyboard icon for button, and check for usingElectron in showing it * Change ctrl+R shortcuts to use new labelling * Exit FS and/or FW when keyboard shortcut modal is opened * Add code comment clarifying where parallel change to shortcut documentation should be * Implement changes from review --------- Co-authored-by: absidue <[email protected]>
Keyboard shortcut modal
Pull Request Type
Related issue
closes #2822
Description
Ctrl+ZShift+? keyboard shortcut (same as YT) + (for non- mobile device sizes only) button at the top of the settings page that opens/closes a modal containing all of the keyboard shortcuts available in FreeTubeft-prompt
logic to check forft-icon-button
s as well, not justft-button
sScreenshots
Testing
Desktop
Additional context