I've coded the following functions to switch the content for divs using keypresses. Basically I display 2 images, which are being changed to another onkeydown. If onkeyup, the image will be restored.
It works beautifully, as long as only one key is being pressed. If I make The keypress shortcut [224+86] (Meta+V), the key released last "stays" onkeydown (no onkeyup is generated for some reason).
//CMD
$(document).keydown(function (e) {
if (e.keyCode == 224)
document.getElementById("loading").innerHTML = '<div style="position: absolute; left: -30px; top: 8px; width: 600px; height:600px; padding: 0px; border: 0px; z-index:200; padding:158px;"><img src="img/mac/1_b.png" /></div>';
});
$(document).keyup(function (e) {
if (e.keyCode != 224)
document.getElementById("loading").innerHTML = '<div style="position: absolute; left: -30px; top: 8px; width: 600px; height:600px; padding: 0px; border: 0px; z-index:200; padding:158px;"><img src="img/mac/1.png" /></div>';
});
//V
$(document).keydown(function (e) {
if (e.keyCode == 86)
document.getElementById("loading2").innerHTML = '<div style="position: absolute; left: 95px; top: 9px; width: 600px; height:600px; padding: 0px; border: 0px; z-index:200; padding:158px;"><img src="img/mac/2_b.png" /></div>';
});
$(document).keyup(function (e) {
if (e.keyCode == 86)
document.getElementById("loading2").innerHTML = '<div style="position: absolute; left: 95px; top: 9px; width: 600px; height:600px; padding: 0px; border: 0px; z-index:200; padding:158px;"><img src="img/mac/2.png" /></div>';
});
Can anyone please point me in the right direction? Thanks so much for any hint!