[...]
Matthias Watermann wrote on 11 mei 2008 in comp.lang.javascript:
MikeB wrote on 10 mei 2008 in comp.lang.javascript:
You may notice that in that I have mentioned that I have found and
tried using accesskey and that the results were erratic and
unpredictable.
[...]
The word "Erratic" I would preserve for inconsistent behavour even
after thorough testing of your programme on each targeted browser.
Building for cross browser compatibility is a teduous task.
Unfortunately it's not "just" a (cross-)browser issue. There's
something else involved: the respective GUI. I stumbled over this
problem some years ago when some users where quite happy with the
pages' access keys while others complained that those access keys were
misleading and wouldn't work. I was able able to find two users with
the very same browser, the same OS and even the same GUI. However, what
was working on one computer didn't at the other's. After experimenting
and changing the access keys we finally figured out what the problem
was: The GUI-setup allowed for defining hotkeys for whatever purpose
(like invoking programs or switching desktops). And if such a GUI-based
hotkey happens to be the same as the one you're using (well, intend to
use) on your web-page the browser won't even get notified that the key
in question was pressed let alone have chance to react on it. And
because every user is free to define her/his favourite hotkeys there's
no chance to use a set of supposedly unused access keys for your
web-page (even if there wouldn't be the usual issues with browser
incompatibilites).
To make a long story short: While access keys are a good idea in
theory, in practise there's no guarantee whatsoever that they will work
anywhere (except, may be, the developers own computer).
Good point, Matthias.
This leaves us with no other option than not to use the Alt and detect
the keys by the onkeydown or onkeypress of the page and also of the
relevant input fields and go from there.
That won't work, I'm afraid. At least there's no guarantee. Just
consider the order of notifications when a key is pressed:
1. OS: usually here's nothing to be afraid of as far I'm aware.
2. GUI: here both the GUI's standard hotkeys as well as user defined
hotkeys are "eating" quite a few keys (each key with an arbitrary
combination of ALT/CTRL/SHIFT can be used); and there's at least GNOME,
KDE, OS/X and WinDos to consider, each of which in various versions.
3. Application: the browser itself as well as any browser plugin may
have hotkeys defined for their own purposes. How many browsers in how
many versions with how many plugins on how many platforms are you
prepared to check out? And how often will you repeat the tests to verify
the results with the respective then current version?
4. Web-page (incl. JavaScript): only those keys which are not used (i.e.
consumed) on a prior level will reach this point. If I configure my
GUI to - say - switch to desktop-1 on ALT-A your fine javascript will
wait for that very key 'till hell freezes over and the sun ceases to
shine or the user looses patience (whatever may happen first).
In consequence this means that you'd have to use key(combinations) that
are so unlikely as to be used already (say: SHIFT-CRTL-ALT-B for "back")
that it's hardly a comfort for the user to use them. And even if you
actually tried something like that, you still can't be sure that there
really is no OS or GUI or user or browser or plugin or ... that doesn't
consume you desired key(s) before the reach your page.
What I tried to say above was simply this: Offer your hotkeys (by means
of the "accesskey" tag attribute) and that's it.
Be happy, if your access keys are working as intended here and there.
But never rely on them. And: Don't waste a second of your valuable time
to implement something that will work by coincidence at best.
Do _not_ expect them to work anywhere. Do _not_ suggest to your readers
that they will work. Especially do _not_ write something like "just press
ALT-X to do this or CRTL-Y for that" on your page. The best possible
outcome for you would be to get complaints (more likely the readers will
just go away probably telling others to avoid your page because "it
doesn't work"). Don't rise your reader's expectations by announcements
which you can't reasonably fulfil (unless you're M$, that is).
That might sound discouraging. But, alas, sometimes it's better to know
what _not_ to do than to try something in vain.
--
Matthias
/"\
\ / ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
X - AGAINST M$ ATTACHMENTS
/ \