pessoal eu quero saber porque não consigo mostrar as teclas digitadas no browser, pra poder movimentar imagens futuramente…
alguém pode me dizer o que fiz de errado?
eu peguei um codigo aqui e ali e cheguei a isso e não consigo sqaber o erro.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="asset/css/normalize.css">
<link rel="stylesheet" href="css/style.css">
<style>
body{
font-family: "Verdana", "Tre"
}
/*-- Formatação de tipografa ------*/
.tit-prin{
color: blue;
font-size: 20px;
}
</style>
<script >
libLetras = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','x','y','z','w'];
mapLetras = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91];
function main(){
canvas = document.getElementById("jogo");
context = canvas.getContext("2d");
posKey = geraPosicao(0,2);
desafio = libLetras[posKey];
context.font = '40pt Calibre';
context.fillstyle = 'blue';
context.fillText(valor, posX, posY);
var posX = 100;
var posY = 120;
var tecla = event.keyCode;
if(true){
document.write(0+tecla);
}
document.addEventListener('keydown', tecla);
alert('Tecla: ' + tecla);
}
</script>
<title>Smart Type</title>
</head>
<body onload="main();" >
<header>
<h2 class="tit-prin"> Smart Type </h2>
</header>
<section >
<canvas id="jogo" width="500" height="500">
</canvas>
</section>
</body>
</html>