I recently started using a Keychron K8 keyboard which comes with a dedicated key for Cortana/Siri.
Here’s how it can be mapped to turning the microphone on and off instead using BetterTouchTool (which is included in Setapp):
1) Open BTT and create a new keyboard shortcut.
2) BTT is now waiting for you to set a key as a trigger. Go ahead and press the voice assistant key.
3) Next click the + to assign an action.
4) Locate/search and select “Run Apple Script (blocking)”.
Paste this code:
if input volume of (get volume settings) is greater than 0 then set volume input volume 0 display notification "Off" with title "Mic" else set volume input volume 100 display notification "On" with title "Mic" end if
Uncheck “Run in background (limited support)”.
When you now press the voice assistant key your microphone should be muted with “Off” system notification. Pressing it again will unmute the mic and show “On” notification.