After implementing `|KeyboardEvent.key|`, `|KeyboardEvent.code|` and `|KeyboardEvent.getModifierState()|`, `|.key|` value for Windows Logo key was declared as "|OS|", `|.code|` value for it was declared as "|OSLeft|" or "|OSRight|" and the modifier state was "|OS|". However, after we shipped them, the standards changed the declarations. `|.key|` became "|Meta|" which is same as Command key in macOS, `|.code|` becaome "|MetaLeft|" and "|MetaRight|" and also Command keys in macOS will become "|OSLeft|"/"|OSRight|" to "|MetaLeft|"/"|MetaRight|", and the modifier state is also aligned to "|Meta|" which is enabled by Command key in macOS. I.e., the Windows Logo keys are treated as Command key in macOS in UI Events world. Therefore, we need to align these things to conform to the standards and align to Chrome.

Additionally, for applying "|Meta|" to Windows Logo keys in Linux, we need to reconsider about the legacy "meta" modifier state of Linux. Typically, it's mapped to Alt-Shift, but we use the highest priority modifier state of modifier keys <https://searchfox.org/mozilla-central/rev/1cbb3aa1ce39581528eb75b08848fe85dd481f20/widget/gtk/nsGtkKeyUtils.cpp#587-598>, it's not exposed to the web within major distributions' default settings (i.e., exposed as "|Alt|" and "|Shift|" modifiers). However, if users customized key mapping to a modifier is pure Meta modifier key, it may be exposed on Firefox. I'm not sure how we should treat this. Currently, I'm think that it should be treated as "|Alt|" because typically "meta" state is mapped to Alt key, but it's just considered without concrete idea. So, I'm fully open about this issue.

Fortunately, the values are not meaningless values like `.keyCode` values. Therefore, web apps can handle Windows Logo key press like this code:

addEventListener("keydown", e => {
  if (e.key === "Meta" || e.key === "OS") {
    // Do something
  }
});

and also modifier state can be treated as:

if (e.getModifierState("OS") || e.metaKey) {
  // Do something
}

Therefore, the risk of this change is lower than changing `.keyCode` values since giving meanings to meaningless values require browser check, but it's not required in this case. (And anyway, Windows Logo key is not typically handled by applications including native apps since they are used for system-wide shortcut keys.)

So, listing up my intention is:

 * Change Windows Logo key |.key| values from "|OS|" to "|Meta|" in
   Windows/Linux
 * Change Windows Logo key |.code| values from "|OSLeft|"/"|OSRight|"
   to "|MetaLeft|"/"|MetaRight|" in Windows/Linux
 * Change Command key |.code| values from "|OSLeft|"/"|OSRight|" to
   "|MetaLeft|"/"|MetaRight|" in macOS
 * Change modifier state of Windows Logo keys from "|OS|" to "|Meta|"
   in Windows/Linux (affecting both |.getModifierState()| and |.metaKey|
 * Treat legacy meta key/modifier in Linux as "|Alt|" key/modifier


       Bugs:

 * Bug 1266437 - [UI Events] getModifierState("Meta") should return
   true when Windows logo key is pressed on Windows and Linux
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1266437> (for
   |getModifierState|)
 * Bug 1232918 - [UI Events-key] Windows logo key on Windows and Linux
   should be treated as "Meta" key
   <https://bugzilla.mozilla.org/show_bug.cgi?id=1232918> (for |key|
   and |code|)


       Specifications:

 * getModifierState()
   <https://w3c.github.io/uievents/#dom-keyboardevent-getmodifierstate>
 * Meta key value <https://www.w3.org/TR/uievents-key/#key-Meta>
 * MetaLeft/MetaRight code values
   <https://w3c.github.io/uievents-code/#code-MetaLeft>


       Platform coverage:

Windows/Linux and macOS (only for `|.code|`)


       Preference:

Unfortunately, not controllable with prefs because the maps are hard coded and too many places refer the values.


       DevTools bug:

N/A


       Other browsers:

 * Blink: Already conformed to the standards
 * WebKit: Already conformed to the standards (|.code| values)


       web-platform-tests:

This is not testable with WPT, but we have some mochitest-chrome tests:

 * Windows keys in Windows
   
<https://searchfox.org/mozilla-central/rev/1cbb3aa1ce39581528eb75b08848fe85dd481f20/widget/tests/test_keycodes.xhtml#2996-3002>
 * Command keys in macOS
   
<https://searchfox.org/mozilla-central/rev/1cbb3aa1ce39581528eb75b08848fe85dd481f20/widget/tests/test_keycodes.xhtml#668-681>
 * Synthesizer for tests
   
<https://searchfox.org/mozilla-central/source/dom/base/test/chrome/window_nsITextInputProcessor.xhtml#2450,2938,3057-3058>

--
Masayuki Nakano<[email protected]>
Working on DOM, Events, editor and IME handling for Gecko

--
You received this message because you are subscribed to the Google Groups 
"[email protected]" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/a/mozilla.org/d/msgid/dev-platform/a4f5d437-5776-9c7d-288f-06d683f7d200%40d-toybox.com.

Reply via email to