Skip to content

Tinykeys 2 #155

@jamiebuilds

Description

@jamiebuilds

Opening this to track some thoughts about a potential next version of this package

Specifically I want to push developers to make more accessible keyboard shortcuts.

  • Declare keyboard shortcuts directly on elements (in the general case)
    • Only visible & focusable & clickable elements
  • Display the shortcut on the clickable element

I'm certain there are edge cases to this, but I think you should have to opt-out of these requirements.

Draft API

In React terms, it would look something like this:

<TinyKeys
  // tinykeys props
  binding="$mod+KeyS" bindingLabel="$mod+S" 
  // button props
  as={Button} onClick={save}
>
	Save
</TinyKeys>
<button>
  Save
  <kbd>Ctrl+S</kbd>
</button>
Save Ctrl+S

By putting the keyboard shortcut on the clickable element you know how the two types of interactions are related

I don't want to make this library very React specific though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions