Plugin
Keyboard Sounds
Adds the Opera GX Keyboard Sounds to Discord
1
/*2
* FiveCord — a Discord client mod3
* Copyright (c) 2025 FiveCord4
* SPDX-License-Identifier: GPL-3.0-or-later5
*/6
7
import { Devs } from "@utils/constants";8
import definePlugin, { OptionType } from "@utils/types";9
10
const sounds = {11
click1: new Audio("https:class="ts-cmt">//github.com/HypedDomi/FiveCord-Plugins/raw/main/Keyboard-Sounds/sounds/click1.wav"),12
click2: new Audio("https:class="ts-cmt">//github.com/HypedDomi/FiveCord-Plugins/raw/main/Keyboard-Sounds/sounds/click2.wav"),13
click3: new Audio("https:class="ts-cmt">//github.com/HypedDomi/FiveCord-Plugins/raw/main/Keyboard-Sounds/sounds/click3.wav"),14
backspace: new Audio("https:class="ts-cmt">//github.com/HypedDomi/FiveCord-Plugins/raw/main/Keyboard-Sounds/sounds/backspace.wav")15
};16
17
const ignoredKeys = ["CapsLock", "ShiftLeft", "ShiftRight", "ControlLeft", "ControlRight", "AltLeft", "AltRight", "MetaLeft", "MetaRight", "ArrowUp", "ArrowRight", "ArrowLeft", "ArrowDown", "MediaPlayPause", "MediaStop", "MediaTrackNext", "MediaTrackPrevious", "MediaSelect", "MediaEject", "MediaVolumeUp", "MediaVolumeDown", "AudioVolumeUp", "AudioVolumeDown"];18
19
const keydown = (e: KeyboardEvent) => {20
if (ignoredKeys.includes(e.code)) return;21
for (const sound of Object.values(sounds)) sound.pause();22
if (e.code === "Backspace") {23
sounds.backspace.currentTime = 0;24
sounds.backspace.play();25
} else {26
const click = sounds[`click${Math.floor(Math.random() * 3) + 1}`];27
click.currentTime = 0;28
click.play();29
}30
};31
32
export default definePlugin({33
name: "Keyboard Sounds",34
description: "Adds the Opera GX Keyboard Sounds to Discord",35
authors: [Devs.FiveCord],36
start: () => document.addEventListener("keydown", keydown),37
stop: () => document.removeEventListener("keydown", keydown),38
options: {39
volume: {40
description: "Volume",41
type: OptionType.SLIDER,42
markers: [0, 100],43
stickToMarkers: false,44
default: 100,45
onChange: value => { for (const sound of Object.values(sounds)) sound.volume = value / 100; }46
}47
}48
});49