Toggle navigation
Run LIVE DEMO
Show CODE
LIVE DEMO PAGE
Updated: 19.06.18 11:06
Keyboard control
<!DOCTYPE html> <html> <head> <title>Keyboard control smartapp2.js example</title> <!-- jQuery --> <script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script> <!-- Bootstrap --> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> <!-- Smartapp --> <script src="https://smartapp.ikx.no/downloads/jquery.smartapp2.js"></script> <!-- Some CSS for your keyboard shortcuts: --> <style> [data-shortkey] { position:relative; } .shortcuts [data-shortkey]:after { content: attr(data-shortkey); position:absolute !important; padding:0px 3px; background:#333; color:#eee; border-radius:2px; font-size:10px; font-family:Consolas; box-shadow: rgba(0,0,0,0.4) 1px 1px 1px; right:-4px; top:-4px; text-transform: uppercase; z-index:990; } </style> </head> <body> <div id="AppContainer"></div> <!-- View1 added through markup --> <div id="View1" class="text-center"> <h1>Keyboard control demo</h1> <h2>You are on view 1/2</h2> <p>Hold down the ALT or CTRL key on your keyboard to show short keys.</p> <a data-shortkey="s" class="btn btn-default" href="#View2">Go to view 2</a> <a data-dlgnav="Dialog1" data-shortkey="d" class="btn btn-default">Show dialog 1</a> </div> <!-- View1 added through markup --> <div id="View2" class="text-center"> <h1>You are on view 2/2</h1> <p>Hold down the ALT or CTRL key on your keyboard.</p> <a data-shortkey="b" class="btn btn-default" href="#View1">Go to view 1</a> <a data-dlgnav="Dialog1" data-shortkey="a" class="btn btn-default">Show dialog 1</a> </div> <!-- Dialog1 added through markup --> <div id="Dialog1" class="modal fade" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">Modal title</h4> </div> <div class="modal-body"> <p>One fine body…</p> </div> <div class="modal-footer"> <button type="button" data-shortkey="q" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div><!-- /.modal --> <script> $(function() { // Initialize app on a DOM container element var $app = $("#AppContainer").smartapp2(); // Register a view on route #Hello (will be default view, as it is registered first) $app.createView("View1", $("#View1")); $app.createView("View2", $("#View2")); $app.createDialog("Dialog1", $("#Dialog1")); // Run the application $app.run(); }); </script> </body> </html>