Why on this page:
https://jsfiddle.net/eddnhc5f/
When I press the key c on Firefox and Microsoft edge, the background is changed before the alert, but in Opera and Chrome, after I press confirm alert.
function getKeyup(key) {
if (key == null) {
keycode = event.keyCode;
// To 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;
// To 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