so I need to show what key is being pressed in my web app , I want to put it in html 5 canvas.
when I'm pressing Q , it will show the Q button.
Here my code(i'm using javascript):
window.addEventListener("keypress",onKeyPress);
function onKeyPress(e)
{
console.log(e.keyCode);
var str = String.fromCharCode(e.keyCode);
console.log(str+":"+e.keyCode);
var tune = new Audio();
if (e.keyCode == 113)
{
tune = new Audio("Assets/Tune/C.mp3");
tune.play();
}
}
can anyone tell me what function do I need to show the key ? If there's already solution, please give me the link, I've tried to search before but can't find anything.
Thanks