konami.html revision 45e6f13936658ddeb74bff8dde445a67419a1995
<!doctype html>
<html>
<head>
<title>Test Page</title>
div {
margin: 1em 0;
}
</style>
</head>
<body class="yui-skin-sam">
<input type="text" value="" id="k"><label for="k"><-- up,up,dn,dn,l,r,l,r,b,a</label>
<ul id="output"></ul>
<!--
<script src="http://yui.yahooapis.com/3.2.0/build/yui/yui-min.js"></script>
<script src="/build/event/event-synthetic.js"></script>
-->
<script>
YUI({
useBrowserConsole: false,
//lazyEventFacade: true,
filter: 'raw'
}).use('event-synthetic', function (Y) {
Y.on('yui:log', function (e) {
});
Y.Event.define('konami', {
on: function (node, sub, ce) {
var guid = Y.guid();
node.on(guid + '|keydown', function (e) {
if (++sub.progress === sub.keys.length) {
ce.fire();
}
} else {
sub.progress = 0;
}
});
Y.mix(sub,{
progress : 0,
keys : [38,38,40,40,37,39,37,39,66,65],
keys : [38,38,40,40,37,39,37,39,66,65],
_evtGuid : guid
});
},
detach: function (node, sub, ce) {
node.detach(sub._evtGuid + '|*');
}
});
Y.one('#k').on('konami', function (e) {
});
});
</script>
</body>
</html>