-
Notifications
You must be signed in to change notification settings - Fork 6
Home
TheMechanic edited this page Apr 27, 2015
·
2 revisions
If you need to use this script in your apps, you need to know some more things. It is necessary to grab the keys used for the navigation. Otherwise, an error "cannot move" will be thrown. In the following sample, don't forget to import lodash.js, r7extlib.js, and mickey.js scripts in the head markups.
<body>
<div id="main">
<ul data-nav-area="li">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
</ul>
</div>
</body>
<script>
var mickey = new Mickey(document.getElementById('main')).init();
// move
R7.grabKey('Up', function(e) { mickey.move('up'); });
R7.grabKey('Right', function(e) { mickey.move('right'); });
R7.grabKey('Down', function(e) { mickey.move('down'); });
R7.grabKey('Left', function(e) { mickey.move('left'); });
// other keys...
R7.grabKey('Enter', function() { apps.onKeyEnter(); });
...
</script>