Skip to content
TheMechanic edited this page Apr 27, 2015 · 2 revisions

Welcome to the mickey.js wiki!

Mickey for the apps

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.

Example

<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>
Clone this wiki locally