EndPwn3Plugins/plugins/osutyping.js

31 lines
1 KiB
JavaScript
Raw Normal View History

2018-05-21 17:02:05 +00:00
exports = {
manifest: {
2018-05-14 01:01:34 +00:00
author: "Cynosphere, janeptrv",
2018-05-13 18:17:49 +00:00
name: "osu! Typing",
description: "Adds typing sounds from osu!."
2018-05-13 18:17:49 +00:00
},
start: function(){
var sounds = [];
for (var i = 1; i < 4; i++) {
2018-05-21 17:02:05 +00:00
sounds.push(new Audio(`https://raw.githubusercontent.com/janeptrv/sounds/master/osu_typing_click${i}.wav`));
2018-05-13 18:17:49 +00:00
}
2018-05-21 17:02:05 +00:00
const backspace = new Audio("https://raw.githubusercontent.com/janeptrv/sounds/master/osu_typing_erase.wav");
2018-05-13 18:17:49 +00:00
var keys = {};
function typingSound(ev) {
for (const sound of sounds) {
sound.pause();
sound.currentTime = 0;
}
backspace.pause();
backspace.currentTime = 0;
if (ev.key == "Backspace" || ev.key == "Delete") {
backspace.play();
} else {
sounds[Math.floor(sounds.length * Math.random())].play();
}
return false;
}
document.addEventListener("keydown", typingSound);
}
}