SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

saveShortcut

Why JS.

tsx
import { saveShortcut } from "@sdxc/ui/app";

Usage

Applied to any element in or beside a form: ⌘S (Ctrl+S elsewhere) submits that form through requestSubmit, while typing included. With several bound forms on a page, the one holding focus saves; with focus outside them all, the only bound form saves.

Signature

typescript
saveShortcut(options?: SaveShortcuts.Options): MixinDescriptor<HTMLElement>

Parameters

ParameterTypeRequiredDescription
optionsSaveShortcuts.OptionsNo

Examples

tsx
<span hidden mix={[saveShortcut({ form: "post-form" })]} />

The events, constants and types its module publishes, each imported from @sdxc/ui/app too.

Constant

SAVE_SHORTCUT

The keys that save, as the shortcut registry spells them.

typescript
const SAVE_SHORTCUT = "mod+s"
Function

bindSaveShortcut

Binds ⌘S to binding.form until signal aborts, through the page's shortcut registry. Every binding on the page agrees on one form per keystroke, so exactly one saves; a keystroke that chooses none is still held back from the browser's save-page dialog.

typescript
bindSaveShortcut(binding: SaveShortcuts.Binding, signal: AbortSignal): void
ParameterTypeRequiredDescription
bindingSaveShortcuts.BindingYesThe form and how it saves.
signalAbortSignalYesRemoves the binding.
Interface

SaveShortcuts.Options

Configuration for saveShortcut.

MemberTypeRequiredDescription
formstringNoThe id of the form ⌘S submits; omit to submit the form the host sits in.
Interface

SaveShortcuts.Binding

One form's answer to ⌘S.

MemberTypeRequiredDescription
formHTMLFormElementYes
savevoidYesSaves the form once ⌘S chose it.
fallbackbooleanNoYields to every other binding of the same form, so a save bar steps aside for the form's own primary save and one keystroke submits once.
@sdxc/ui

Can’t find it? Contact us