I'm using Firefox on MacOS and a specific access key isn't working:
<label id="name_label" for="name" accesskey="n">Name</label>
<input id="name" name="name" value="" tabindex="1" type="text" />
This works on Safari and Chrome, but not Firefox. When I use Control+Option+n, the focus is not set on the "name" field. There are 2 other fields in the form, and their access keys work as expected. There are no conflicts on the page for the access key (i.e. accesskey="n"
is only defined once). There are no conflicts on the page for the target element name (i.e. id="name"
is only defined once).
I can use the developer tools to change the accesskey on that label to something else (e.g. w
) and it works, so the link between the <label>
and the <input>
is correct. There is something about the n
specifically.
I haven't been able to find any information online about any "access keys that don't work (for some reason)" but I'm starting to wonder if the n
access key conflicts with something in Firefox.
Installed plug-ins are uBlock Origin, Firefox Devtools ADB Extension, and Power Close.
I mostly figured out what is causing this and came up with a workaround that's good enough for my purposes though I don't know if it will be useful for yours.
On macOS, when you type Option-N you're telling the OS that you want to put a tilde accent over the next character you type. This makes the Option-N key sequence a "dead key", which means that it doesn't generate any actual characters until another key is pressed.
Now, when you type Ctrl-Option-N, that shouldn't be treated as a dead key, right? But either the macOS keyboard input layer or Firefox (and Thunderbird, which uses the Firefox code base), I'm not sure which, is still treating it as one. I confirmed this by intercepting the key event in JavaScript and examining the event structure; the
key
field of the structure is set toDead
. I imagine this will happen not just with the N key but with any key that is used on macOS for generating accented characters.As a workaround in my Thunderbird add-on I added a keydown handler which check is Ctrl and Alt (a.k.a. Option) are true on the key event, and the
key
field is set toDead
, and theCode
field is set toKeyN
, and if so, then I invoke the function that should have been invoked automatically by the access key. Here's a code snippet suitable for a keydown event handler:You can see the whole thing here if you're curious, but the code above is enough to get you started.
This only works if the user hasn't remapped the "N" key on their keyboard, because we're using the pre-mapping key code instead of the mapped key sequence, but it'll work fine for the vast majority of people.
I've reported this to Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1850454
I've also added telemetry to my add-on to find out how many people are running into this, because I figure if a lot of people are running into it that'll help me convince someone at Mozilla to spend some time trying to figure it out.