This topic is locked

Keyboard Shortcuts for your application

11/6/2021 10:37:50 AM
PHPRunner Tips and Tricks
mbintex author

If you ever thought of keyboard shortcuts in your application, let´s for a quick jump to a help screen or for quickly moving around the moduls, here is the solution:

Download or link to this small Javascript:

https://wangchujiang.com/hotkeys/

and then add some javascript like this to your headers.htm file - you find that unter templates in the Editor-Screen.

<script src="https://unpkg.com/hotkeys-js/dist/hotkeys.min.js"></script>;
<script type="text/javascript">
hotkeys('alt+e', function(event, handler) {
event.preventDefault();
});

hotkeys('alt+a,alt+o,alt+e, alt+v, alt+n', function (event, handler){
switch (handler.key) {
case 'alt+a': location.href = 'Adressen_list.php';
break;
case 'alt+o': location.href = 'Objekte_list.php';
break;
case 'alt+e': location.href = 'Einheiten_list.php';
break;
case 'alt+v': location.href = 'Vertraege_list.php';
break;
case 'alt+n': location.href = 'Navigator_list.php';
break;
default: alert(event);
}
});
</script>
</script>

With the first part "event.preventDefault" you forbid the browser to use it´s own shortcuts in case you want to use a key combination that is already in use.

In the handler-part you say, what should happen, for example a location change to a different page of your PHPRunner solution. Of course it could be anything else - own Javascript or some call to the Javascript API of PHPRunner. Show a dialog with the Dialog API for example.

Should work with all current main browsers.