Follow along with the runnable example. This guide walks through the Device buttons example in
corti-examples — bootstrap your build from it or use it as reference.This guide is about wiring a device’s buttons. For choosing the right microphone hardware for audio quality, see Recommended Microphones.
Connect a device
Use thedictation_support library, which decodes each device’s raw HID reports into semantic button events. Create a DictationDeviceManager, subscribe to button events via addButtonEventListener, and call requestDevice() from a user gesture (a Connect button click). See the device buttons example in corti-examples for the setup code.
From button reports to actions
dictation_support reports a bitmask of the buttons currently pressed — a level, not an edge. Holding Record keeps its bit set across successive reports. To get discrete presses and releases, diff the previous mask against the new one.
JavaScript
JavaScript
Drive recording and commands
Route each resolved effect to its target. Recording effects calldictation.startRecording(), dictation.stopRecording(), or dictation.toggleRecording() on the Dictation Web Component; command effects dispatch client-side against your own registry, exactly as in the Commands guide.
The Corti API does not execute button-triggered commands — a command-mapped button fires locally against your own command handler. Only spoken command phrases are recognized server-side.
Activation model
Tie the buttons to the microphone you’re actually recording with: only let them drive a surface while that surface has the handheld device selected as its mic. Selecting a built-in mic leaves the buttons inert; selecting the handheld activates them. This mirrors how the Web Component’s keyboard push-to-talk / toggle keys drive the samestartRecording / stopRecording / toggleRecording methods.
Next steps
Commands
Build the command handler that button-mapped commands dispatch to.
Recommended Microphones
Choose the right handheld or headset mic for dictation.
Example code
The complete, runnable Device buttons example in
corti-examples.Please contact us for help or questions.