Skip to content

KeyboardEvent: ctrlKey false on key up of the control key #45056

Description

@amelted

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Element/keyup_event

What specific section or headline is this issue about?

the keyup event has a non documented and unexpected behavior

What information was incorrect, unhelpful, or incomplete?

With the keydown event, its property, 'e.ctrlKey' will be reported correctly, however with the keyup event, it doesn't set the ctrlKey property at all, regardless of if they keycode is ctrl or not. Is this intended behavior that's simply not documented anywhere?

What did you expect to see?

I expected to see a disclaimer about this strange behavior.

Do you have any supporting links, references, or citations?

umm see below

Do you have anything more you want to share?

Image

super short html snippet that replicates it. This behavior doesn't make any sense and to me is this way on both firefox and chromium, versions 152.0 and 150.0.7871.186 respectively. So I feel like it should be documented. Is this truly the intended ecma standard?

<head>
  <script>
    function showChar(e) {
      output.textContent += `${e.type}: "${e.key}"\n${e.type} ctrlKey: ${e.ctrlKey}\n`;
    }
    window.onload = ()=>{
       document.addEventListener("keydown", showChar)
       document.addEventListener("keyup", showChar);
    }
  </script>
</head>
<body>
  <pre id="output"></pre>
</body>

MDN metadata

Page report details

Metadata

Metadata

Assignees

No one assigned

    Labels

    Content:WebAPIWeb API docshelp wantedIf you know something about this topic, we would love your help!

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions