jQuery jAM, Season 6

Exercise 14.01

Censored Keyboard

	 
   var field = document.querySelector("input");
   var codes = ["81","87","88"];
   field.addEventListener("keydown", function(event){
   	for(var i = 0; i < codes.length; i=i+1) 
   		if(event.keyCode == codes[i])
   			{
     		event.preventDefault();
     		document.body.style.background = "red";
   			}
       });
    
    addEventListener("keyup", function(event){
      if(document.body.style.background = "red")
        document.body.style.background = "#ffffff";
    });
   
	 
	

To open the JavaScript console, press F12 or on MAC press COMMAND-OPTION-I.