(ems) add menu toggle button

This commit is contained in:
radius 2016-09-11 02:37:56 -05:00
parent ec6eb0ccad
commit 2c01ffcdb9
2 changed files with 40 additions and 0 deletions

View File

@ -94,6 +94,9 @@
<button class="btn btn-primary disabled" id="btnFullscreen" onclick="Module.requestFullScreen()" title="Fullscreen">
<span class="fa fa-desktop" id="icnAdd"></span> <span class="sr-only">Fullscreen</span>
</button>
<button class="btn btn-primary" id="btnMenu" onclick="keyPress(112);">
<span class="fa fa-bars" id="btnMenu"></span> <span class="sr-only">Menu</span>
</button>
</li>
</div>
</ul>

View File

@ -337,3 +337,40 @@ $(function() {
//$('#dropdownMenu1').text(localStorage.getItem("core"));
});
});
function keyPress(k)
{
kp(k, "keydown");
setInterval(function(){kp(k, "keyup")}, 1000);
}
kp = function(k, event) {
var oEvent = document.createEvent('KeyboardEvent');
// Chromium Hack
Object.defineProperty(oEvent, 'keyCode', {
get : function() {
return this.keyCodeVal;
}
});
Object.defineProperty(oEvent, 'which', {
get : function() {
return this.keyCodeVal;
}
});
if (oEvent.initKeyboardEvent) {
oEvent.initKeyboardEvent(event, true, true, document.defaultView, false, false, false, false, k, k);
} else {
oEvent.initKeyEvent(event, true, true, document.defaultView, false, false, false, false, k, 0);
}
oEvent.keyCodeVal = k;
if (oEvent.keyCode !== k) {
alert("keyCode mismatch " + oEvent.keyCode + "(" + oEvent.which + ")");
}
document.dispatchEvent(oEvent);
document.getElementById('canvas').focus();
}