1
0
mirror of https://github.com/hexolan/konami-code-snippets.git synced 2026-05-20 11:39:22 +01:00

feat: remove added listener within core

docs: expand readme and show example
This commit is contained in:
2026-04-03 17:31:31 +01:00
parent e5b03ce4fd
commit 317034ef5d
5 changed files with 28 additions and 11 deletions
+25 -3
View File
@@ -10,13 +10,35 @@ Read more about the Konami Code from the associated [Wikipedia entry](https://en
### JSDelivr ### JSDelivr
stub You can use this as a library within your web applications.
minified js (at set version tag) #### Links
Version 1.0.0: <https://cdn.jsdelivr.net/gh/hexolan/konami-code-snippets@1.0.0/src/core.min.js>
Latest Version: <https://cdn.jsdelivr.net/gh/hexolan/konami-code-snippets/src/core.min.js>
#### Example
```html
<html>
<body>
(...content)
<script src="https://cdn.jsdelivr.net/gh/hexolan/konami-code-snippets/src/core.min.js" />
<script>
document.addEventListener("keydown", handleKonami(() => {
console.log('konami!');
}));
</script>
</body>
</html>
```
### Direct ### Direct
stub An example of direct usage can be seen within the source of [examples/redirect.html](/examples/redirect.html).
## License ## License
+1 -1
View File
@@ -3,7 +3,7 @@
"version": "0.1.0", "version": "0.1.0",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"minify": "minify src/main.js > src/main.min.js" "minify": "minify src/core.js > src/core.min.js"
}, },
"author": "Declan Teevan <dt@hexolan.com>", "author": "Declan Teevan <dt@hexolan.com>",
"license": "MIT", "license": "MIT",
+1 -6
View File
@@ -12,9 +12,4 @@ let handleKonami = (e) => (callback) => {
} else { } else {
sequenceStep = 0; sequenceStep = 0;
} }
} }
// Example usage:
document.addEventListener("keydown", handleKonami(() => {
console.log('konami!');
}));
+1
View File
@@ -0,0 +1 @@
let a=['ArrowUp','ArrowUp','ArrowDown','ArrowDown','ArrowLeft','ArrowRight','ArrowLeft','ArrowRight','b','a'];let b=0;let c=e=>A=>{if(a[b]===e.key){b+=1;b===a.length&&(b=0,A())}else b=0};
-1
View File
@@ -1 +0,0 @@
let a=['ArrowUp','ArrowUp','ArrowDown','ArrowDown','ArrowLeft','ArrowRight','ArrowLeft','ArrowRight','b','a'];let b=0;document.addEventListener('keydown',(e=>A=>{if(a[b]===e.key){b+=1;b===a.length&&(b=0,A())}else b=0})(()=>console.log('konami!')));