Triggering OS shortcut keys is not possible in a browser as it would be a security risk. I don't think you'll be able to do that exactly.
However there is a related Web Speech API that works in Chrome and Safari. It does not work in all browsers and the experience varies by browser (Safari on Mac uses OS internals, Chrome seems to have its own engine). Here's a generic article on using it: https://12daysofweb.dev/2021/speech-api/
A very-basic use might look like:
function logSpeech() {
const SR = window.SpeechRecognition || window.webkitSpeechRecognition;
const recognition = new SR();
recognition.lang = "en-US";
recognition.onresult = function (event) {
const transcript = event.results[0][0].transcript;
console.log(transcript)
}
// in chrome this ends automatically
recognition.start();
};