summaryrefslogtreecommitdiffstats
path: root/content/main.js
blob: 7189312dd30b7186749fed3069110002a5ee0468 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(() => {
    document.body.classList.remove('t-no-js');
    document.body.classList.add('t-js');

    const enableFocusIndicator = e => {
        if (e.key !== 'Tab') {
            return;
        }

        document.body.classList.add('t-keyboard');
        document.removeEventListener('keydown', enableFocusIndicator);
        document.addEventListener('mousedown', disableFocusIndicator);
    }

    const disableFocusIndicator = () => {
        document.body.classList.remove('t-keyboard');

        document.removeEventListener('mousedown', disableFocusIndicator);
        document.addEventListener('keydown', enableFocusIndicator);
    }

    document.addEventListener('keydown', enableFocusIndicator);
})();