Can someone help me figure out this issue?
https://jsfiddle.net/eddnhc5f/
I've noticed that when I press the key c
on Firefox and Microsoft Edge, the background changes before the alert pops up. However, in Opera and Chrome, the background changes after the alert is confirmed.
function getKeyup(key) {
if (key == null) {
keycode = event.keyCode;
// For Mozilla
} else {
keycode = key.keyCode;
}
}
function TEST() {
document.body.style.backgroundColor = "BLACK";
alert('Hello');
return false;
}
function getKey(key) {
if (key == null) {
keycode = event.keyCode;
// For Mozilla
} else {
keycode = key.keyCode;
}
if (keycode == 67) {
//alert(condcheck);
TEST();
return false;
}
}
$(document).ready(function() {
$(document).keydown(function(eventObj) {
getKey(eventObj);
});
$(document).keyup(function(eventObj) {
getKeyup(eventObj);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
TEST