Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added keydown functionality #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions about.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@
</div>








<script src="js/keyevents.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@
<p class="nav">Please press F2 for <a href="work.html"><b>WORK</b></a> and Del for <a href="about.html"><b>ABOUT</b></a></p>
</div>

<script src="js/keyevents.js"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions js/keyevents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
document.addEventListener("keydown",(event) => {
switch(event.keyCode){
case 46: //DEL Key
document.location = "about.html";
event.preventDefault();
return false;
case 112: //F1
document.location = "index.html";
event.preventDefault();
return false;
case 113: //F2
document.location = "work.html";
event.preventDefault();
return false;
default:
return true;
}
});
7 changes: 4 additions & 3 deletions project.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@
</div>








<script src="js/keyevents.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions test.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
</div>
</div>

<script src="js/keyevents.js"></script>
</body>
</html>

Expand Down
3 changes: 2 additions & 1 deletion work.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
</div>

</div>


<script src="js/keyevents.js"></script>
</body>
</html>