Excesskey - my first Opera extension!
Monday, November 1, 2010 2:29:57 AM
Update 2010-12-01: version 1.21 now available. As is a change log
I have been messing around with the extension stuff for a while. The project is to improve the usability of accesskeys, and version 1.1 actually works (although there are a lot of improvements I want to make).
This page will serve as the user documentation for the foreseeable future (which means I will add 'update this' to the list of things I need to do as I make changes).
(I realise this isn't actual magic yet - people like Gez Lemon have made extensions to improve accesskey behaviour in browsers before. Opera has the best accesskey implementation today but we can improve. This is an attempt to prototype what I think a good accesskey implementation would do).
This screenshot shows the icon (without the tooltip) when there are accesskeys on the page, plus the open accesskey menu:
The current version does some basic useful stuff:
- Status Icon
- See in the UI if accesskeys are defined for the current page
- Clean the keys
- The extension makes sure each thing with an accesskey has a unique key. If you're only using the keyboard, the current Opera implementation doesn't let you activate a second control that uses the same access key
- New in 1.2 Select your preferred keys
- By default, numerals and latin letters are assigned as accesskeys (which is fine if you have a qwerty keyboard setup). But you can use the preferences to set any keys you can enter, e.g. 1 2 й ي ц ب z ø as demonstrated in the screenshot below. I recommend using keys that are easy for you to type (no modifier required) and providing a lot of them. It doesn't yet handle running out of keys very gracefully
Installing and using
You need a current version of Opera (11+). Download and install the extension. If you want it to work on https pages and/or private tabs, you set that in the privacy option - either when installing, or in the extension manager (go to tools->extensions->manage extensions).
Once it is installed, open a new tab and go to (for example) Dev.Opera (which has 8 accesskeys defined)... In an ideal world, you see the little icon go green, you press shift-esc and a table of links with numbers and/or letters come up. You can press one of those numbers or letters to follow the link directly. Of course not all pages use accesskeys, so sometimes the icon will end up with a red X over it and the tooltip will tell you that there are no accesskeys. This is a beta and an experiment, so if it doesn't behave like that, maybe the following information is helpful...
Set up the right Opera preferences...
Don't forget to press the "save" button when you change a preference in opera:config.
You should set the preference "Always load user JS" on so it works on pages that don't have a script tag (although this is probably still unreliable due to the way I coded it).
I also re-map the shortcut to open accesskeys from shift-esc to '.' - although you could also use a mouse gesture (or voice shortcut if you have Opera's voice plugin activated). Go to Opera's preferences -> advanced -> shortcuts then select which set you want to change (keyboard? Mouse gestures?), and press the relevant 'edit' button. You could just search for accesskey and it should show the current one - double-click on the shortcut and type what you want. You may want to enable single-key shortcuts too (I do that anyway).
Setting excesskey preferences
You can set preferences for the extension itself. So far you can set exactly one preference - the list of keys it will consider acceptable as accesskeys.
The preferences dialogue is currently only available in the extension manager (e.g. tools -> extensions -> manage extensions) when you click the funny cog wheel to the right of the uninstall button.
You should set as many keys as you can - currently it doesn't handle running out of available keys very nicely...
To Do list...
This is pretty big ... but at least it no longer has "make it work" at the top Also, it's not necessarily in priority order, although it should be.
Make it more robust
Handle limited key sets gracefully
Currently it fixes the sort of problems that arise if someone uses
accesskey="oops, this isn't right" (by the rather dumb heuristic of assigning the first letter). But if you have more elements using accesskeys than you have available keys, it just gives up. That shouldn't be a problem when there are 36 keys, but if you want to limit it to half a dozen I would like to handle that too. Specifically the idea is that if it's going to run out you get "next set" / "previous set", and then it assigns as many as are available.
Handle dynamically added elements
No problems, does that.
Leave the page DOM alone?
Right now (because it uses the native Opera menu) it actually changes the accesskeys on the elements themselves. While I don't think that's a problem in the real world, it is possible that some other code is looking at them. If I replace the menu, I would also be able to leave the original page alone and maintain the assigned interactions in the extension code. (Or even make that an option - sometimes whatever relies on knowing the accesskeys will be more useful if it sees them change, other times not, among the use cases I can envisage for doing that).
Make its own menu
One of the things I would like to do is have the accesskey menu appear when you click on the button (or activate it by keyboard, but that's a different issue in the code). I think I can do this in the accesskey popup, although I haven't quite thought my way to the end of that process. Apart from being an obvious thing to do, this would allow several more improvements:
- You could have the text style matching that of the page, and contrast, font size and so on would be user-configurable.
- Being HTML it will be properly navigable by keyboard as well as mouse. The big benefit for this is making it easier to use things like single-switch keyboards - the sort of situation where accesskeys are Max nested elements reached useful.
- I can re-implement the way links are labelled. Right now they're less than perfect - I would get the opportunity to improve them, and to add images or icons in the menu which might be helpful. Especially in a long page.
Having made http://my.opera.com/chaals/blog/swaplang I now have a pretty reasonable idea how to do this. I think it will take a day or two for me to get it reasonable...
Max nested elements reached
Done. Available at Max nested elements reached
Max nested elements reached
Max nested elements reachedMax nested elements reachedMax nested elements reachedMax nested elements reached