Skip to content

Conversation

@brianteeman
Copy link
Contributor

@brianteeman brianteeman commented Mar 10, 2019

This is a proof of concept for a new plugin offering keyboard shortcuts in the Joomla admin based on previous work by @jneubauer

For testing I have created the following shortcut keys

Save - Alt/Opt S
Save & Close - Shift + Alt/Opt S
Save & New - Shift + Alt/Opt N
Save as Copy - Shift + Alt/Opt C
Cancel/Close - Alt/Opt X
New - Alt/Opt N
Help - Alt/Opt H
Options - Alt/Opt

Alt/Opt means Alt key on Windows/Linux and Option key on Mac

When testing please report the operating system, browser, language AND keyboard layout/lang

This is a proof of concept for a new plugin offering keyboard shortcuts in the Joomla admin based on previous work by @jneubauer

It uses the awesome mousetrap.js (please read the documentation there https://craig.is/killing/mice)

For testing I have created the following shortcut keys

General
1. mod+shift+1  Return to control panel

Item
2. mod+shift+2  Save
3. mod+shift+3  Save and Close
4. mod+shift+4  Save and New
5. mod+shift+5  Save as copy
6. mod+shift+6  Cancel

Lists
1. mod+shift+7  New
2. j h          Help

mod is the ctrl key on windows and cmd key on mac
the key combination "j h" above is an example of gmail style shortcuts - press the keys in sequence not together

By default none of these shortcuts will work when you are in a text or textarea field

please no comments on codestyle or es6 etc - this is a proof of concept to see if it something we want
@joomla-cms-bot joomla-cms-bot added NPM Resource Changed This Pull Request can't be tested by Patchtester PR-4.0-dev labels Mar 10, 2019
@joomla-cms-bot joomla-cms-bot added the Language Change This is for Translators label Mar 10, 2019
@dgrammatiko
Copy link
Contributor

fwiw the ctrl+s was already implemented (but George manage to undo that) here: joomla/40-backend-template#55

Also it worth copying the tinyMCE bits from there, so the combo works also when the cursor is in the editors iframe

@brianteeman
Copy link
Contributor Author

As I said - by default NONE of these shortcuts work when the cursor is in a text area. Its just a config option to enable if desired

@dgrammatiko
Copy link
Contributor

@brianteeman also you don't need an extra script, just add the logic in the toolbar.js

@brianteeman
Copy link
Contributor Author

mousetrap is much better

@dgrammatiko
Copy link
Contributor

mousetrap is much better

I always prefer less code and of course no dependencies, but that's me...

@brianteeman
Copy link
Contributor Author

I prefer maintainable code with no bus factor

@dgrammatiko
Copy link
Contributor

I prefer maintainable code with no bus factor

Just because you're pulling something from NPM is not automagically more maintainable or has a greater bus factor...

@ReLater
Copy link
Contributor

ReLater commented Mar 10, 2019

Is a great and welcome feature!

@dgrammatiko
Copy link
Contributor

Just to make my self clear here, when I said

also you don't need an extra script, just add the logic in the toolbar.js

I meant the build/media_source/plg_system_shortcuts/js/shortcuts.js not the mousetrap.js.
So all your code in the shortcuts.js can happily live in the toolbar, actually it'e exactly the place it belongs

@brianteeman
Copy link
Contributor Author

Ah. I misunderstood you there.

As it's a proof of concept it's better on its own. If accepted it can be moved into that file of course

@brianteeman
Copy link
Contributor Author

Also it depends if people want it to be configurable by the user (or even disabled) or not. And anyway toolbar is probably not the best place as even in this example there are some that work on pages without a toolbar

@dgrammatiko
Copy link
Contributor

@brianteeman it can still be configurable, also by reading the code this works only with the toolbar buttons.
Also by reviewing the code of mousetrap.js I would say it's an overkill and probably not good fit for J4, reason the script is mainly polyfilling IE 6,7,8,9 which none is supported by J4

@zwiastunsw
Copy link
Contributor

zwiastunsw commented Mar 11, 2019

From the point of view of a11y, this is extremely important and necessary functionality.
I miss the general toolbar shortcut key (of course, I remember that there will be quick access via SkipTo). My suggestion - instead of a shortcut Return to Control panel let the shortcut to the toolbar.
As to combination "j h" - I will ask my friend (blind accessibility expert) for their opinion.

@brianteeman
Copy link
Contributor Author

The keys I used are just examples

@C-Lodder
Copy link
Member

Great idea. Does this also include a hint list in the actual admin panel?

@brianteeman
Copy link
Contributor Author

Not yet. But it's supported by mousetrap

@dgrammatiko
Copy link
Contributor

@wilsonge fwiw if was still the JS leader I wouldn't accept this mousetrap script to enter the project's dependencies

@ghost ghost added the J4 Issue label Apr 5, 2019
@ghost ghost changed the title [4.0] RFC Administrator Shortcut Keys [4.0] [RFC] Administrator Shortcut Keys Apr 11, 2019
@brianteeman brianteeman changed the title [4.0] [RFC] Administrator Shortcut Keys [4.0] Shortcut Keys May 21, 2019
@brianteeman
Copy link
Contributor Author

This should now be in native js and not use any external libraries. I have updated the original description.

@brianteeman
Copy link
Contributor Author

Sorry @dgrammatiko @wilsonge you were right - it didnt need the library at all

@brianteeman
Copy link
Contributor Author

Updating branch to trigger drone

@wilsonge
Copy link
Contributor

This works. However altKey either doesn't trigger or is overriden by browser behavior in chrome on my mac. option x still cuts, option s still downloads the web page, option h goes to the home page in chrome. all the commands are usable if using the actual alt key instead of the option key.

@brianteeman
Copy link
Contributor Author

The docs say that alt on windows and opt on mac are triggered by altKey https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/altKey

Can you go to https://keycode.info/ and tell me the results you get for alt and opt on your mac

@wilsonge
Copy link
Contributor

Screenshot 2019-05-24 at 23 36 46

Screenshot 2019-05-24 at 23 36 52

This is alt and option

@brianteeman
Copy link
Contributor Author

I can only think then that the mdn documentation I linked to is incorrect and they keystrokes are ALT on both and OSx

@wilsonge
Copy link
Contributor

keyboard

Trying to figure it out tbh. Like the docs says the option key. that seems different to the command key. And the symbol is the one I have on my alt key.

I think the meta key is correct on macs https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/metaKey

However saying that we start to override a bunch of browser short codes (nearly all the combinations you have are already native browser combinations)

@brianteeman
Copy link
Contributor Author

Using the meta key really isn't an option

@brianteeman
Copy link
Contributor Author

What needs to happen to move this forward?

It really needs some testers with non UK keyboards and non english language settings. @alikon @Quy @SharkyKZ

@Quy
Copy link
Contributor

Quy commented Jun 11, 2019

Tested by placing cursor in Title field and pressing Alt + S. Got the same screenshot for Alt.

Windows 10, US standard keyboard layout.

Chrome 74.0.3729.169
Nothing happens.

Firefox 67.0.1. Dropdown menu appears.
shortcut

@brianteeman
Copy link
Contributor Author

Tested by placing cursor in Title field and pressing Alt + S. Got the same screenshot for Alt.

It is SHIFT and Alt

@Quy
Copy link
Contributor

Quy commented Jun 11, 2019

Same result.

@brianteeman
Copy link
Contributor Author

might be a firefox bug - will investigate

@SharkyKZ
Copy link
Contributor

SharkyKZ commented Jun 11, 2019

In Edge, Shift + Alt + S result in Save, not Save & Close. Alt + X results in browser's Settings and More menu being opened. Alt + O doesn't do anything.

Windows 10, US layout.

@brianteeman
Copy link
Contributor Author

I can confirm that the keyboard shortcuts I chose clash with some of the native browser shortcuts in firefox - grrh

@brianteeman
Copy link
Contributor Author

I am closing this. It really serves little value especially regarding accessibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language Change This is for Translators NPM Resource Changed This Pull Request can't be tested by Patchtester

Projects

None yet

Development

Successfully merging this pull request may close these issues.