You've already forked konami-code-snippets
mirror of
https://github.com/hexolan/konami-code-snippets.git
synced 2026-05-20 11:39:22 +01:00
feat: expand examples
fix: library usage
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Konami Code Snippets: Redirect</title>
|
||||
<title>Konami Code Snippets: Nolib Usage</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Enter the code.</p>
|
||||
<p>Konami Code</p>
|
||||
|
||||
<script>
|
||||
const keySequence = ["ArrowUp", "ArrowUp", "ArrowDown", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowLeft", "ArrowRight", "b", "a"];
|
||||
@@ -0,0 +1,19 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Konami Code Snippets: Direct Usage</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>Konami Code</p>
|
||||
|
||||
<script>
|
||||
const konamiSequence = ["ArrowUp", "ArrowUp", "ArrowDown", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowLeft", "ArrowRight", "b", "a"]; let konamiStep = 0, handleKonami = callback => e => { konamiSequence[sequenceStep] === e.key ? (konamiStep += 1, konamiStep === konamiSequence.length && (konamiStep = 0, callback())) : konamiStep = 0 };
|
||||
|
||||
function konamiCallback() {
|
||||
window.location.href = `https://github.com/hexolan/konami-code-snippets`;
|
||||
}
|
||||
|
||||
document.addEventListener("keydown", handleKonami(konamiCallback));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,22 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Konami Code Snippets</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>Konami Code - O(1)</p>
|
||||
|
||||
<sup>Note: currently just lower case `b` and `a` keys.</sup>
|
||||
|
||||
<sup>(as using <code>event.code</code> not deprecated <code>event.keyCode</code>)</sup>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/hexolan/konami-code-snippets@main/src/core.min.js"></script>
|
||||
<script>
|
||||
function konamiCallback() {
|
||||
window.location.href = `https://github.com/hexolan/konami-code-snippets`;
|
||||
}
|
||||
|
||||
document.addEventListener("keydown", handleKonami(konamiCallback));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user