var cam; function keyDown(event) { if (event.keyCode == 49) { var display = document.getElementById('screen'); cam = 0; display.innerHTML = '' } if (event.keyCode == 50) { var display = document.getElementById('screen'); cam = 1; display.innerHTML = '' } if (event.keyCode == 51) { var display = document.getElementById('screen'); cam = 2; display.innerHTML = '' } if (event.keyCode == 52) { var display = document.getElementById('screen'); display.innerHTML = '' } if (event.keyCode == 37) { var request = new XMLHttpRequest(); request.open("get", "http://172.22.80.56:8080/cam/" + cam + "/control/left", false); request.send(); return false; } if (event.keyCode == 38) { var request = new XMLHttpRequest(); request.open("get", "http://172.22.80.56:8080/cam/" + cam +"/control/up", false); request.send(); return false; } if (event.keyCode == 39) { var request = new XMLHttpRequest(); request.open("get", "http://172.22.80.56:8080/cam/" + cam +"/control/right", false); request.send(); return false; } if (event.keyCode == 40) { var request = new XMLHttpRequest(); request.open("get", "http://172.22.80.56:8080/cam/" + cam +"/control/down", false); request.send(); return false; } }