Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
IT Security DownloadsGitHub Release: ollama/ollama v0.34.4-rc0 (23.09.2026)(23.09.2026 um 02:53 Uhr)
Sichere ProgrammierungMy fact-checker said CONFIRMED about a group that doesn't exist(23.09.2026 um 02:13 Uhr)
Sichere ProgrammierungZero-Friction Payment Architectures for Global Scalability(23.09.2026 um 02:20 Uhr)
IT Security DownloadsGitHub Release: ollama/ollama v0.34.4-rc0 (23.09.2026)(23.09.2026 um 02:53 Uhr)
Sichere ProgrammierungMy fact-checker said CONFIRMED about a group that doesn't exist(23.09.2026 um 02:13 Uhr)
Sichere ProgrammierungZero-Friction Payment Architectures for Global Scalability(23.09.2026 um 02:20 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Add Arrow-Key Shortcuts to a Confirmation Dialog Without Breaking Accessibility

Two buttons in a confirmation dialog look simple: Cancel and Confirm. Keyboard behavior makes the component a small state machine. A recent MonkeyCode change gives us a concrete example. Issue #862 and PR #863 add these shortcuts to the…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Two buttons in a confirmation dialog look simple: Cancel and Confirm. Keyboard behavior makes the component a small state machine.



A recent MonkeyCode change gives us a concrete example. Issue #862 and PR #863 add these shortcuts to the slash-command confirmation:




ArrowLeft  -> focus Cancel
ArrowRight -> focus Confirm






The reviewed implementation at commit c58bcd4 moves focus through button refs. That is a useful extra interaction. It is not a replacement for the dialog's accessibility foundation.






Keep the baseline first



For an alert-style confirmation, users still need:




  • an accessible name and description;

  • focus moved inside when the dialog opens;


  • Tab and Shift+Tab constrained to dialog controls;


  • Escape to dismiss when cancellation is allowed;

  • visible focus;

  • focus returned to the trigger after close;

  • actual buttons whose labels explain the actions.



The WAI-ARIA Authoring Practices Alert Dialog Pattern describes the modal semantics and keyboard foundation. Left/right mapping is a product shortcut, not a required AlertDialog convention. That means we must not steal keys from the established behavior around it.






Isolate the extra mapping



The companion keyboard.mjs starts with a pure function:




export function arrowAction(key) {
if (key === "ArrowLeft") return "cancel";
if (key === "ArrowRight") return "confirm";
return null;
}






The event handler ignores unrelated and modified keys:




export function handleDialogArrow(event, controls) {
const action = arrowAction(event.key);
if (!action || event.altKey || event.ctrlKey || event.metaKey) return false;
event.preventDefault();
controls[action].focus();
return true;
}






Notice what is absent: no handler for Tab, Shift+Tab, Escape, or Enter. The native <dialog> and buttons in the minimal demo retain their normal jobs. In a React component, use a well-tested modal/dialog primitive for focus containment and dismissal, then add this narrow handler to its content.






A complete minimal dialog



The included dialog.html uses native semantics:




<button id="open">Run slash command</button>
<dialog id="confirm" aria-labelledby="title" aria-describedby="description">
<h2 id="title">Run this slash command?</h2>
<p id="description">The task may change files in the workspace.</p>
<form method="dialog">
<button id="cancel" value="cancel">Cancel</button>
<button id="accept" value="confirm">Confirm</button>
</form>
</dialog>






On open, the demo focuses Cancel. That conservative default avoids placing initial focus on a potentially destructive action. On close, it restores focus to the trigger and announces the result in an aria-live status.






Test the mapping and the interaction



Run the pure mapping test:




node test-keyboard.mjs






Expected output:




PASS arrows move focus; Tab, Escape, and modified arrows remain untouched






Then serve the directory over HTTP and test dialog.html with keyboard only. The manual checklist is:




  1. Open from the trigger; focus is visible on Cancel.

  2. Press Right; focus moves to Confirm without executing it.

  3. Press Left; focus returns to Cancel.

  4. Use Tab and Shift+Tab; focus stays within the modal.

  5. Press Escape; the dialog closes and focus returns to the trigger.

  6. Reopen, focus Confirm, press Enter; the button activates once.

  7. Zoom to 200% and repeat without losing labels or focus indication.



Also test with a screen reader. Arrow keys can participate in screen-reader navigation modes, so the control must remain understandable without discovering the shortcut. Never make the arrows the only way to choose an action.



The design rule is pleasantly small: add shortcuts as an enhancement around semantic controls, and prove that the keys you did not handle still work.




Disclosure: I contribute to the MonkeyCode project. The product behavior is based on the linked public issue, PR, and pinned source; the standalone mapping tests were run locally, not as a full MonkeyCode accessibility audit.


Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Add Arrow-Key Shortcuts to a Confirmation Dialog Without Breaking Accessibility

Thematisch verwandte Begriffe: ArrowKey, Shortcuts, Confirmation, Dialog · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-17636 | IBM Financial Transaction Manager (FTM) for RedHat OpenShift could allow…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick