Keyboard Navigation

SmarkForm adds keyboard navigation to supported fields. The exact behavior also depends on the form’s markup, native controls, browser, and enabled features.

Keyboard shortcut reference

Use the shortcut according to the focused control and the form structure. Each example link opens a small playable preview below.

Shortcut and context Result Try it
Enter / Shift+Enter in a single-line SmarkForm field Move to the next/previous SmarkForm field; triggers are skipped. Field sequence
Plain Enter in a <textarea> Insert a newline. Textarea example
Shift+Enter in a <textarea> Move backward to the previous field. No Ctrl is needed. Textarea example
Ctrl+Enter / Ctrl+Shift+Enter in a <textarea> Move forward/backward through fields; this does not jump between outer form/list contexts. Textarea example
Ctrl+Enter / Ctrl+Shift+Enter outside a textarea, without a jump boundary Move to the next/previous sibling form/list context, following the nearest available component boundary. Scalar and singleton list items are treated as fields; at an edge, navigation stops. Nested contexts
The same Ctrl shortcuts inside a role:"jump-boundary" component Move to the next/previous available sibling with that role and restore its last focused field. At the role boundary’s edge, do nothing—do not fall back to inner navigation. Jump boundaries
Alt+Enter / Alt+Shift+Enter Open a collapsed <details> while moving forward/backward into its fields. From a textarea, use Ctrl+Alt+Enter to move forward; Alt+Shift+Enter moves backward. Collapsed sections
Shift+Space on a SmarkForm field in a <summary> or open details body Toggle the disclosure; from the open body, focus returns to its summary field. Details list
Tab / Shift+Tab Use the browser’s normal sequential focus order. Hotkey-equipped list-item Add/Remove triggers are skipped; outer controls remain reachable. Tab flow and hotkeys

Hold Ctrl by itself to reveal configured action hotkeys where the example includes the corresponding hint CSS. These action hotkeys are separate from the field-navigation shortcuts in the table.

Enter / Shift+Enter Navigation

Press Enter to move forward to the next field, and Shift+Enter to move backward. This field-navigation shortcut skips buttons and other non-field components. Use Tab and Shift+Tab for the browser’s normal sequential focus order; disabled controls and the form’s authored markup affect that order.

🔗
❓
<div id="myForm">
  <p>
    <label data-smark>First name:</label>
    <input data-smark type="text" name="first">
  </p>
  <p>
    <label data-smark>Last name:</label>
    <input data-smark type="text" name="last">
  </p>
  <p>
    <label data-smark>Email:</label>
    <input data-smark type="email" name="email">
  </p>
  <p>
    <label data-smark>Message:</label>
    <textarea data-smark name="message"></textarea>
  </p>
</div>
const myForm = new SmarkForm(document.getElementById("myForm"));

Press Enter in a single-line field to move to the next one; Shift+Enter moves backward. In a textarea, plain Enter inserts a newline, Ctrl+Enter moves forward, and Shift+Enter moves backward. The shared JSON editor is disabled so its controls do not add extra steps to this navigation sequence.

Ctrl+Enter Between Forms and Lists

Outside a <textarea>, Ctrl+Enter moves to the next available sibling form or list; Ctrl+Shift+Enter moves backward. SmarkForm follows the component hierarchy, not page-specific concepts: a list of form items moves between its sibling items, while a list of scalar or singleton items is treated as one field in its surrounding context. Disabled or hidden destinations are skipped. At the edge of the nearest sibling group, navigation stops rather than wrapping or jumping to a more distant parent.

Add the SmarkForm option role:"jump-boundary" to sibling form/list containers when navigation should jump between those containers before following the ordinary inner boundary. For example, column lists with that role let a task field move focus to the corresponding remembered field in the next column. When a focused field is inside a jump boundary, reaching either end of its marked sibling group does nothing; it does not fall back to moving within the inner list. Ordinary hierarchical navigation is used only when there is no jump-boundary ancestor.

Inside a <textarea>, these keys keep their field-navigation behavior: Ctrl+Enter moves forward and Ctrl+Shift+Enter moves backward. Plain Enter still inserts a newline.

🔗
❓
<div id="myForm">
  <div data-smark='{"type":"form","name":"east"}'>
    <label data-smark>East section:</label>
    <input data-smark id="east-lane" name="lane" placeholder="Section name">
    <textarea data-smark id="east-notes" name="notes" placeholder="Multiline notes"></textarea>
    <input data-smark id="east-after-notes" name="after_notes" placeholder="Next field">
    <ul class="task-list" data-smark='{"type":"list","name":"tasks","of":"form","min_items":1}'>
      <li>
        <input data-smark name="task" placeholder="Task">
        <input data-smark name="owner" placeholder="Owner">
      </li>
    </ul>
  </div>
  <div data-smark='{"type":"form","name":"hidden"}' style="display:none">
    <input data-smark name="title" placeholder="Hidden destination">
  </div>
  <div data-smark='{"type":"form","name":"disabled"}'>
    <fieldset disabled>
      <input data-smark name="title" placeholder="Disabled destination">
    </fieldset>
  </div>
  <div data-smark='{"type":"form","name":"west"}'>
    <label data-smark>West section:</label>
    <input data-smark id="west-lane" name="lane" placeholder="Section name">
    <ul class="scalar-list" data-smark='{"type":"list","name":"values","of":"input","min_items":2}'>
      <li><input data-smark name="value" placeholder="Scalar list value"></li>
    </ul>
  </div>
  <div data-smark='{"type":"form","name":"standby"}'>
    <input data-smark id="standby-title" name="title" placeholder="Standby section">
  </div>
  <ul class="sections-list" data-smark='{"type":"list","name":"sections","of":"form","min_items":1}'>
    <li>
      <input data-smark name="section" placeholder="Section">
      <input data-smark name="detail" placeholder="Section detail">
    </li>
  </ul>
  <div data-smark='{"type":"form","name":"north","role":"jump-boundary"}'>
    <input data-smark id="north-first" name="first" placeholder="North first field">
    <input data-smark id="north-last" name="last" placeholder="North last field">
  </div>
  <div data-smark='{"type":"form","name":"south","role":"jump-boundary"}'>
    <input data-smark id="south-first" name="first" placeholder="South first field">
    <input data-smark id="south-last" name="last" placeholder="South last field">
  </div>
</div>
const myForm = new SmarkForm(document.getElementById("myForm"), {
    "value": {
  "east": {
    "lane": "North",
    "notes": "Keep the delivery entrance clear.\nCall before arrival.",
    "after_notes": "Ready",
    "tasks": [
      {"task":"Mark the route","owner":"Ari"},
      {"task":"Set up signs","owner":"Noah"}
    ]
  },
  "hidden": {"title":"Hidden destination"},
  "disabled": {"title":"Disabled destination"},
  "west": {"lane":"South","values":["One","Two"]},
  "standby": {"title":"Backup"},
  "sections": [
    {"section":"Entry","detail":"North gate"},
    {"section":"Finish","detail":"Main field"}
  ],
  "north":{"first":"One","last":"Two"},
  "south":{"first":"Three","last":"Four"}
}
});

From East section, press Ctrl+Enter to skip the hidden and disabled forms and reach West section. From a task row, the same shortcut moves to the next task form; at the last row it stops instead of escaping to West. The scalar Values list behaves as one field in its surrounding form hierarchy, so moving forward from one of its items skips its other scalar items and reaches Standby.

Try Ctrl+Enter in the Notes textarea: it moves to the next field in East; plain Enter inserts a newline. Ctrl+Shift+Enter moves backward between composite contexts. Forms and lists remember their last focused field, so re-entering a context restores that position. If the remembered field has been removed, hidden, or disabled, focus falls back to the nearest remaining available field in the context.

Tab-Flow Exclusion for Hotkey-Equipped Buttons

Hotkey-equipped addItem and removeItem triggers inside their list context are removed from sequential Tab order, so a long list does not require tabbing through every row action. Hotkey-equipped controls outside that list context remain in Tab order, including an outer Add button.

  • Inner buttons (inside list context): Removed from Tab flow — users can activate them via their hotkey instead.
  • Outer buttons (siblings of the list): Kept in Tab flow — with min_items: 0, the only way to create the first item is via the outer add button, which must remain keyboard-accessible.

This tab-order behavior is limited to list addItem/removeItem triggers with hotkeys in their list context. SmarkForm sets tabindex="-1" when the trigger has no authored tabindex; an explicit authored value is preserved. If an action is essential, provide a visible control that remains in the normal keyboard order; do not rely on a CSS-generated hotkey hint as its only description.

🔗
❓
<div id="myForm">
  <button data-smark='{"action":"addItem","context":"items","hotkey":"+"}' title="Add">➕ Add</button>
  <button data-smark='{"action":"removeItem","context":"items","hotkey":"Delete","preserve_non_empty":true}' title="Remove empty">🧹</button>
  <ul data-smark='{"type":"list","name":"items","min_items":1}'>
    <li>
      <input data-smark type="text" name="item" placeholder="Item name">
      <button data-smark='{"action":"removeItem","hotkey":"-"}' title="Remove this">➖</button>
      <button data-smark='{"action":"addItem","hotkey":"+"}' title="Insert here">➕</button>
    </li>
  </ul>
</div>
#myForm [data-hotkey] { position: relative; }
#myForm [data-hotkey]::after {
  content: "Ctrl+" attr(data-hotkey);
  position: absolute; top: 0.75em; left: 0;
  font-size: .7em; background: #333; color: #fff;
  padding: 1px 4px; border-radius: 3px; white-space: nowrap;
}
const myForm = new SmarkForm(document.getElementById("myForm"), {
    "value": {"items":[{"item":"Review the agenda"},{"item":"Confirm the venue"},{"item":"Send invitations"}]}
});

Press Tab through the form — the outer ➕ Add/🧹 buttons are reachable, but the inner ➖/➕ buttons inside each list item are skipped. Hold Ctrl to reveal their hotkey shortcuts instead.

The shared JSON editor is disabled because its controls would add unrelated stops to the Tab order being demonstrated.

Hold Ctrl to discover available hotkeys — each trigger button with a hotkey can show a visual hint when the form includes the corresponding CSS.

Alt+Enter for Collapsed Sections

When navigating with Enter / Shift+Enter, fields inside a closed <details> element are skipped. To navigate into them, hold Alt while pressing Enter — SmarkForm automatically opens any closed <details> ancestors along the path. When moving forward from a <textarea>, keep Ctrl held as well (Ctrl+Alt+Enter); plain Enter inserts a newline there. For backward navigation into a preceding closed section, use Alt+Shift+Enter.

This allows you to keep optional sections collapsed by default while still being able to navigate into them when you need to fill data.

Sequential Enter navigation follows SmarkForm fields, not the browser’s native <summary> focus stop. Each address row below is a SmarkForm form in the list, with a field in its summary. A bare summary can still toggle the native disclosure, but focus there is not a field in SmarkForm’s navigation tree; the next Enter cannot continue from that point into the section’s fields.

🔗
❓
<div id="myForm">
  <p>
    <label data-smark>Full name:</label>
    <input data-smark type="text" name="name">
  </p>
  <p>
    <label data-smark>Email:</label>
    <input data-smark type="email" name="email">
  </p>
  <fieldset>
    <span data-smark='{"type":"label"}'>Addresses:</span>
    <div class="addresses-list" data-smark='{"type":"list","name":"addresses","of":"form","min_items":1,"max_items":6}'>
      <details data-smark='{"type":"form"}'>
        <summary>
          <input data-smark type="text" name="label" aria-label="Address label" placeholder="Home or work">
          <button data-smark='{"action":"removeItem"}' type="button" title="Remove address">🗑️</button>
        </summary>
        <p>
          <label data-smark>Street:</label>
          <input data-smark type="text" name="street">
        </p>
        <p>
          <label data-smark>City:</label>
          <input data-smark type="text" name="city">
        </p>
        <p>
          <label data-smark>ZIP:</label>
          <input data-smark type="text" name="zip">
        </p>
      </details>
    </div>
    <button data-smark='{"action":"addItem","context":"addresses"}' type="button">➕ Add address</button>
  </fieldset>
  <p>
    <label data-smark>Final comments:</label>
    <textarea data-smark name="final_comments" placeholder="Notes for the whole form"></textarea>
  </p>
</div>
const myForm = new SmarkForm(document.getElementById("myForm"), {
    "value": {
  "name": "Taylor Morgan",
  "email": "taylor@example.com",
  "addresses": [
    {"label":"Home","street":"42 River Lane","city":"Brookside","zip":"12345"},
    {"label":"Work","street":"8 Market Street","city":"Brookside","zip":"12346"}
  ],
  "final_comments": "Call before delivery."
}
});

With the Work address collapsed, focus its summary input and press Enter: focus moves to Final comments, skipping the hidden address fields. Shift+Enter moves back to that address’s summary. From there, Alt+Enter opens the address and focuses Street. Shift+Space from an address field folds it and returns focus to the summary input; another Shift+Space opens it without losing that field.

Each list item is a form, and the input in its <summary> keeps sequential navigation in SmarkForm’s component tree. A native summary without a SmarkForm field can still toggle the disclosure, but Enter cannot resume from that native focus stop. The shared JSON editor is disabled so its controls do not extend the keyboard sequence shown here.

Using <details> as List Items

A powerful design pattern is to wrap each list item in a <details> element with the item’s key identifying field placed inside the <summary>. This way, even when collapsed, the key information remains visible so the user can quickly scan the list, while the full details expand on click.

SmarkForm fields inside the <details> work exactly as they would anywhere else — the browser handles the show/hide toggle natively. Shift+Space on a field inside a <summary> toggles its <details> section; on a field in the open body it folds the section and returns focus within its summary (to its first focusable child, or to the summary itself). Alt+Enter provides a separate way to navigate into a collapsed section. Use semantic markup and test focus and announcements with your target assistive technology.

The contacts example below preserves the key field inside each collapsed summary. Its co-located test checks Space/Shift+Space, forward/backward list navigation, and Alt+Enter / Alt+Shift+Enter into hidden fields.

🔗
❓
<div id="myForm">
  <div data-smark='{"name":"contacts","type":"list","min_items":1,"export_empties":false}'>
    <details>
      <summary>
        <input data-smark type="text" name="fullname" placeholder="Full name">
      </summary>
      <div class="contact-details">
        <input data-smark type="email" name="email" placeholder="Email">
        <input data-smark type="tel" name="phone" placeholder="Phone">
        <button data-smark='{"action":"removeItem","failback":"clear","hotkey":"Delete"}' title="Remove">🗑</button>
      </div>
    </details>
  </div>
  <button data-smark='{"action":"addItem","context":"contacts","hotkey":"+"}'>➕ Add contact</button>
  <textarea data-smark name="notes" placeholder="Notes about this contact list"></textarea>
</div>
#myForm {
  font-family: sans-serif;
}
#myForm details {
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-bottom: 6px;
  padding: 4px 8px;
}
#myForm summary {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
#myForm summary::before {
  content: "▶";
  font-size: .75em;
  transition: transform .15s;
  flex-shrink: 0;
}
#myForm details[open] > summary::before {
  transform: rotate(90deg);
}
#myForm summary input {
  flex: 1;
  min-width: 0;
  font-weight: bold;
  border: none;
  background: transparent;
  outline: none;
}
#myForm .contact-details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0 2px 1.2em;
}
#myForm .contact-details input {
  flex: 1;
  min-width: 120px;
}
#myForm .contact-details button {
  margin-left: auto;
}
#myForm textarea[name="notes"] {
  display: block;
  width: 100%;
  min-height: 60px;
  margin-top: 8px;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
  box-sizing: border-box;
  resize: vertical;
}
/* Hold Ctrl to reveal hotkey hints. */
#myForm [data-hotkey] { position: relative; }
#myForm [data-hotkey]::after {
  content: "Ctrl+" attr(data-hotkey);
  position: absolute; top: 0.75em; left: 0;
  font-size: .7em; background: #333; color: #fff;
  padding: 1px 4px; border-radius: 3px; white-space: nowrap;
}
const myForm = new SmarkForm(document.getElementById("myForm"), {
    "value": {
  "contacts": [
    {"fullname":"Alice Smith","email":"alice@example.com","phone":"+1 555 100 0001"},
    {"fullname":"Bob Jones","email":"bob@example.com","phone":"+1 555 100 0002"},
    {"fullname":"Carol White","email":"carol@example.com","phone":"+1 555 100 0003"}
  ],
  "notes": ""
}
});// Native details plus SmarkForm keyboard navigation; no custom JS is needed.

Maintain a contact list with expandable details

Try it: Edit a contact name in the summary, expand its details, and use Enter, Shift+Enter, Alt+Enter, and Alt+Shift+Enter to test forward/backward navigation across collapsed list items.

The shared JSON editor is disabled because its controls would add extra fields and tab stops to this keyboard-navigation example.