Last active
June 11, 2020 22:00
-
-
Save Srushtika/34b522d3b94e0560b936c1d6631dc0cc to your computer and use it in GitHub Desktop.
Code snippet 34 - For multiplayer space invaders article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let nickname = ""; | |
let nicknameInput = document.getElementById("nickname"); | |
function setNickname() { | |
localStorage.clear() | |
nickname = nicknameInput.value; | |
localStorage.setItem("nickname", nickname); | |
} | |
if(nicknameInput){ | |
nicknameInput.addEventListener("keyup", function(event) { | |
event.preventDefault(); | |
if (event.keyCode === 13) { | |
document.getElementById("go-span").click(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment