Skip to content

[mediaqueries-5] Detect physical keyboard (keyboard capable of shortcuts?) #3871

@birtles

Description

@birtles

From stackoverflow: https://stackoverflow.com/questions/36976117/css-media-query-for-whether-a-physical-keyboard-is-attached

Use case: I want show keyboard shortcut labels in my menu / tooltips but only when the user has a physical keyboard.

Rationale (taken directly from the above SO issue):

  • nobody would use a soft-keyboard this way even if they could
  • the visual display of the keyboard shortcut takes up valuable real-estate
  • it's perhaps confusing, or at least inelegant, to display keyboard shortcuts in a keyboardless context

Apparently some people are doing horrible hacks like using @media (hover: hover) and (pointer: fine) { ... } to detect if there is a mouse/trackpad and assuming that means there is a keyboard too.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions