Plugin

Keyboard Sounds

Adds the Opera GX Keyboard Sounds to Discord

index.ts
Download

Source

src/plugins/keyboardSounds/index.ts
1/*
2 * FiveCord — a Discord client mod
3 * Copyright (c) 2025 FiveCord
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7import { Devs } from "@utils/constants";
8import definePlugin, { OptionType } from "@utils/types";
9
10const 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
17const 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
19const 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
32export 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