https://github.com/maechabin/jquery.cb-konami.js
jQuery Plugin "KONAMI" Code
https://github.com/maechabin/jquery.cb-konami.js
Last synced: 3 days ago
JSON representation
jQuery Plugin "KONAMI" Code
- Host: GitHub
- URL: https://github.com/maechabin/jquery.cb-konami.js
- Owner: maechabin
- Created: 2014-10-30T11:57:47.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-18T11:27:28.000Z (about 11 years ago)
- Last Synced: 2025-02-26T17:44:15.783Z (over 1 year ago)
- Language: JavaScript
- Homepage: http://mae.chab.in/archives/2448
- Size: 2.49 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#jquery.cb-Konami.js
WebサイトにKonamiコマンドを実装するjQueryプラグイン。
##概要
キーボードでKonamiコマンド**「上上下下左右左右BA」**を打った後に、何か任意の処理を実行させる機能を実装することができます。
以下の例では、キーボードの[↑] + [↑] + [↓] + [↓] + [←] + [→] + [←] + [→] + [B] + [A]
を打った後に、「konami」とアラートが表示されます。
```js
$(window).cbKonami(function () {
alert("konami");
});
```
##実装方法
jQueryとjquery.cbkonami.jsをページに読み込みます。
```html
```
<body>の閉じタグの直前に以下を挿入。cbKonamiメソッドの引数には、コナミコマンド入力後に発動させたい処理(関数)を指定。
```js
$(window).cbKonami();
```
###実装例1
```js
var foo = function () {
console.log("bar"):
};
$(window).cbKonami(foo);
```
###実装例2
```js
$(window).cbKonami(function () {
console.log("bar");
});
```
##デモ
[http://jsrun.it/maechabin/6DxD](http://jsrun.it/maechabin/6DxD)
##ライセンス
MIT license