Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

script to add a button to simulate tab key for mobile users

AldareAldare Member Posts: 8
So there was a request earlier today on newbie for the ability to simulate pressing the tab button for targeting while on a mobile device. If you add a new button in the buttons section add the following to the script section of the button you will have your non-tab tab button that is clickable in the nexus UI

******************************** SCRIPT BEGINS BELOW
function simulateKey (keyCode, type, modifiers) {
var evtName = (typeof(type) === "string") ? "key" + type : "keydown";
var modifier = (typeof(modifiers) === "object") ? modifier : {};

var event = document.createEvent("HTMLEvents");
event.initEvent(evtName, true, false);
event.keyCode = keyCode;
for (var i in modifiers) {
event[i] = modifiers[i];


// Setup some tests

var onKeyEvent = function (event) {
var state = "pressed";
if (event.type !== "keypress") {
state = event.type.replace("key", "");
console.log("Key with keyCode " + event.keyCode + " is " + state);

document.addEventListener("keypress", onKeyEvent, false);
document.addEventListener("keydown", onKeyEvent, false);
document.addEventListener("keyup", onKeyEvent, false);

// Using the function
simulateKey(9, "up");
simulateKey(9, "press");


  • KrightKright Member Posts: 1
    I was the requester and this is phenomenal - works perfectly.

    Thank you so much Aldare!
  • AldareAldare Member Posts: 8
    @Kright Glad it works if you need any other Nexus help shoot me a note. 
Sign In to Comment.