TAB shortcut-key play voice for Duolingo

TAB shortcut-key play voice for Duolingo (タブキーで発音を聞く)

// ==UserScript==
// @name         TAB shortcut-key play voice for Duolingo
// @namespace    TAB shortcut-key play voice for Duolingo
// @version      0.8
// @description  TAB shortcut-key play voice for Duolingo (タブキーで発音を聞く)
// @author       meguru
// @license MIT
// @match        *://*.duolingo.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    function playSound(evt) {
        const key = {
            tab: 9,
            a: 65
        }

        if (evt.keyCode === key.tab) {
            document.dispatchEvent(new KeyboardEvent("keydown", { key: " ", ctrlKey: true }));
            evt.preventDefault();
        }
    }

    document.addEventListener("keydown", playSound, false);
})();