TOOLGEIST ↗
213 EDITIONS

ACQUISITION & LICENSING DESK

Direct Foundry Enquiry

Specify your target edition or studio requirements. We respond within one business day with direct source archive delivery and licensing credentials.

WebGL & Motion November 2, 2026 218 words · 1 min read

How to Build an Accessible Command-K Search Palette in WordPress With Vanilla JS

How to Build an Accessible Command-K Search Palette in WordPress With Vanilla JS
Replace slow server-side search pages with a sub-millisecond <dialog> Command-K palette powered by a compact WordPress JSON index.

1. Why Traditional WordPress ?s= Search Pages Feel Dated

Standard WordPress search forces visitors to type a query, submit a form, wait for an uncached PHP page reload, and scan a generic vertical list. For multi-niche portfolios, documentation hubs, and theme marketplaces like Kiln’s 200-edition archive, a native HTML <dialog> Command-K palette delivers instant feedback on every keystroke.

Using <dialog.showModal()> gives you native Escape-key dismissal, backdrop styling via ::backdrop, and built-in focus trapping without installing a single external React or modal dependency.

Clean hangar horizon
Fig 01. You can test this exact Command-K pattern live in the Kiln top navigation bar right now.
document.addEventListener( 'keydown', function ( e ) {
    if ( ( e.metaKey || e.ctrlKey ) && e.key.toLowerCase() === 'k' ) {
        e.preventDefault();
        document.getElementById( 'cmd-palette' ).showModal();
    }
} );

2. Keyboard Navigation, Arrow Keys & Live Region Announcements

A great Command-K palette should feel effortless without touching a mouse. Bind ArrowDown and ArrowUp to move an aria-selected="true" highlight across matching rows, and trigger navigation when the user presses Enter. Debouncing input filtering is unnecessary when searching <500 items in memory—filtering synchronously on input keeps perceived latency under 1ms.

FAQ — Does embedding a 200-item JSON index bloat HTML? A compact array of title, slug, and category tags for 200 items compresses to roughly 5–8KB gzipped—far lighter than a single thumbnail image.