How does this look so far?
<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft® HTML Help Workshop 4.1">
<Title>Virtual Phone</Title>
</HEAD>
<BODY>
document.addEventListener("keydown", () => {
console.log("key pressed");
});
document.addEventListener("keydown", (e) => {
let audio;
switch (e.keyCode) {
// keycodes can be found online:
JavaScript Key Code List & Table | Toptal®
case 48:
audio = new Audio("Rotary Pulse Dial 0.ogg");
break;
case 49:
audio = new Audio("Rotary Pulse Dial 1.ogg");
break;
case 50:
audio = new Audio("Rotary Pulse Dial 2.ogg");
break;
case 51:
audio = new Audio("Rotary Pulse Dial 3.ogg");
break;
case 52:
audio = new Audio("Rotary Pulse Dial 4.ogg");
break;
case 53:
audio = new Audio("Rotary Pulse Dial 5.ogg");
break;
case 54:
audio = new Audio("Rotary Pulse Dial 6.ogg");
break;
case 55:
audio = new Audio("Rotary Pulse Dial 7.ogg");
break;
case 56:
audio = new Audio("Rotary Pulse Dial 8.ogg");
break;
case 57:
audio = new Audio("Rotary Pulse Dial 9.ogg");
}
document.querySelector("#hookswitch").addEventListener("click", function() {
let audio = new Audio("USA Dial Tone 1.ogg");
audio.loop = false;
audio.play();
});
<div role="switch" aria-labelledby="id-label">
<label for="Hookswitch Status"
<button type="button"
role="switch"
id="hookswitch">Hookswitch Status
<span class="on" aria-hidden="true">
On
</span>
<span class="off" aria-hidden="true">
Off
</span>
</label>
</button>
</div>
<audio id="USADialtone" src="Call Progress Tones/USA Dial Tone 1.ogg"></audio>
<audio id="Rotary Pulse Dial 1" src="Rotary Pulse Dials/Rotary Pulse Dial 1 Wind Up.ogg"></audio>
<audio id="Rotary Pulse Dial 1" src="Rotary Pulse Dials/Rotary Pulse Dial 1 Wind Down.ogg"></audio>
<audio id="Rotary Pulse Dial 2" src="Rotary Pulse Dials/Rotary Pulse Dial 2 Wind Up.ogg"></audio>
<audio id="Rotary Pulse Dial 2" src="Rotary Pulse Dials/Rotary Pulse Dial 2 Wind Down.ogg"></audio>
<audio id="Rotary Pulse Dial 3" src="Rotary Pulse Dials/Rotary Pulse Dial 3 Wind Up.ogg"></audio>
<audio id="Rotary Pulse Dial 3" src="Rotary Pulse Dials/Rotary Pulse Dial 3 Wind Down.ogg"></audio>
<audio id="Rotary Pulse Dial 4" src="Rotary Pulse Dials/Rotary Pulse Dial 4 Wind Up.ogg"></audio>
<audio id="Rotary Pulse Dial 4" src="Rotary Pulse Dials/Rotary Pulse Dial 4 Wind Down.ogg"></audio>
</BODY>
</HTML>