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: remove added listener within core
docs: expand readme and show example
This commit is contained in:
@@ -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
@@ -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",
|
||||||
|
|||||||
@@ -12,9 +12,4 @@ let handleKonami = (e) => (callback) => {
|
|||||||
} else {
|
} else {
|
||||||
sequenceStep = 0;
|
sequenceStep = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example usage:
|
|
||||||
document.addEventListener("keydown", handleKonami(() => {
|
|
||||||
console.log('konami!');
|
|
||||||
}));
|
|
||||||
Vendored
+1
@@ -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};
|
||||||
Vendored
-1
@@ -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!')));
|
|
||||||
Reference in New Issue
Block a user