Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

Under a list

Show a list's keys so reviewers can move with J and K, tick with X and search with a slash.

A review queue
Show code
<div data-shortcut-scope>
    <input id="q" type="search" />
    <ul>…<a class="request-link" href="…">…</a>…</ul>
    <app-shortcut-legend items=".request-link" search="#q">
        <app-shortcut key="j" label="Next request"></app-shortcut>
        <app-shortcut key="k" label="Previous request"></app-shortcut>
        <app-shortcut key="/" label="Search"></app-shortcut>
        <app-shortcut key="a" label="Approve" target="#approve"></app-shortcut>
    </app-shortcut-legend>
</div>

Keys on the actions

Put a key on the action it runs, so the key shows on the button as well as in the legend.

Approve with the A key
Show code
<app-button shortcut="a">Approve</app-button>

Grouped, opened from a menu

Group the legend under headings, and open it from a menu item when the page has no key to press.

Review menu
Show code
<app-shortcut-legend id="legend-grouped" trigger="false">
    <app-shortcut key="j" label="Next request"></app-shortcut>
    <app-shortcut key="a" label="Approve" group="Decide"></app-shortcut>
    <app-shortcut key="r" label="Reject" group="Decide"></app-shortcut>
    <app-shortcut key="n" label="Add a note" group="Notes"></app-shortcut>
</app-shortcut-legend>
<button type="button" data-wui-shortcuts-open="#legend-grouped">Keyboard shortcuts</button>

Every option

Every value of every prop, one cell each.

shortcuts: the rows

no app-shortcut rows (default)
<app-shortcut key="j" label="Next request">
group="Decide" under its own heading
onPress (React only): runs the row's action; Razor uses target
target="#every-option-approve": clicks that control on its key

open

open="false": closed
open="true": the sheet shown open

onOpenChange

onOpenChange (React only): called when the sheet opens or closes

trigger

trigger="true" (default)
trigger="false": no button; ?, open or a data-wui-shortcuts-open element opens it

items

items=".legend-demo-link": no visible effect; J and K move between the matching items

search

search="#legend-q": no visible effect; / focuses the matching field

className

class="legend-demo-extra": extra classes on the legend root

Guidance

What to do, and what to avoid.

Use it when

  • A queue or list someone clears every day.
  • A screen whose frequent actions have single-key shortcuts.

Reach for something else when

  • Screens used now and then. → visible buttons only
  • Phone-only screens (no keyboard). → visible buttons only

Reference

Try every prop, read the full list, and check keyboard and screen reader behaviour.

a review queue just ?
true false
React, generated from the controls
<AppShortcutLegend shortcuts={shortcuts} />
Razor, the same props
<app-shortcut-legend>
    <app-shortcut key="j" label="Next request"></app-shortcut>
    <app-shortcut key="a" label="Approve" target="#approve"></app-shortcut>
</app-shortcut-legend>

5 props. The 4 most used come first.

Used on most screens 4 props

PropTypeDefaultDescription
itemsdefault - string - CSS selector of the items that J and K move between, inside the scope.
searchdefault - string - CSS selector of the field that / focuses.
triggerdefault true bool true false renders no button; the sheet opens from ?, open, or a data-wui-shortcuts-open element.
opendefault - bool - Controlled open state of the sheet.

Less common 1 props

PropTypeDefaultDescription
app-shortcutdefault - child - A row: key (one character, or Enter, Esc, /) and label (required), and target, a selector the key clicks, and group, the heading it sits under. ? is always the last row.

Screen reader

3 notes
  • A toggle button opens the sheet, which is a dialog; the button reports aria-haspopup, aria-expanded and aria-controls, and carries aria-keyshortcuts for the ? key.
  • Keys typed into a field, or held with Ctrl, Cmd or Alt, do nothing, so typing is never taken over.
  • Esc or a click outside closes the sheet, and the close button is named.