Passwort abfrage und tastertur abfangen in array gespeichert
by Aaron von Schassen
HTML
<div id="ausgabe"></div>
CSS
#ausgabe{
position:absolute;
top:0px;
left:0px;
width:100%;
height:100%;
font-size:100px;
text-align:center;
}
JavaScript
start()
function start(){
var sPuffer = new String;
document.onkeydown = function(event) {
sPuffer+=event.key;
document.getElementById('ausgabe').style.background="none";
document.getElementById('ausgabe').innerHTML='';
var pass = ["hallo", "das", "macht", "man", "nicht"];
for (var i=0; i < pass.length; i++){
var fund=sPuffer.indexOf(pass[i])
console.log(sPuffer)
if(fund!=-1){
console.log(fund)
//$('#ausgabe').html(sPuffer);
document.getElementById('ausgabe').style.background="green";
document.getElementById('ausgabe').innerHTML=pass[i]+' Erkannt';
sPuffer=null;
}
}
}
}