Skip to content

Instantly share code, notes, and snippets.

@chalkygames123
Created October 7, 2020 10:51
Show Gist options
  • Save chalkygames123/bd68718d2167793dc75fbbdd78103dec to your computer and use it in GitHub Desktop.
Save chalkygames123/bd68718d2167793dc75fbbdd78103dec to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<style>
#container {
height: 100px;
background-color: #ccc;
transition: height 0.5s;
}
#container.hidden {
height: 0;
visibility: hidden;
transition: height 0.5s, visibility 0s 0.5s;
}
</style>
</head>
<body>
<div id="container"></div>
<script>
const container = document.getElementById("container");
window.addEventListener("keydown", (e) => {
if (e.key === "Enter") {
container.classList.toggle("hidden");
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment