To ensure that a user dismisses a dialog and cancels arrow events until they do so, you can create a global variable. Here is an example of how you can implement this on your page:
var can_use_keys = false;
apprise('Hi all, Welcome to my site inspired by the original Xbox 360 NXE Dashboard. Navigation can be done using the Arrow Keys Left and Right', {
'animate' : true,
verify : 'true'
}, function(r) {
if(r) {
can_use_keys = true;
}
});
$(".dashboard_panels > div").dashboard({
point : 'end'
});
$.dashboard.create();
$('body').keydown(function(event) {
if(can_use_keys === true) {
if(event.which == '39') {
$.dashboard.navigate('right');
}
if(event.which == '37') {
$.dashboard.navigate('left');
}
if(event.which == '49') {
$.dashboard.position('init');
}
if(event.which == '50') {
$.dashboard.position('middle');
}
if(event.which == '51') {
$.dashboard.position('end');
}
if(event.which == '77') {
$.dashboard.toggle();
}
} else {
return false;
}
});
Alternatively, you can directly place the key binding function within the apprise callback function like this:
apprise('Hi all, Welcome to my site inspired by the original Xbox 360 NXE Dashboard. Navigation can be done using the Arrow Keys Left and Right', {
'animate' : true,
verify : 'true'
}, function(r) {
if(r) {
$('body').keydown(function(event) {
if(event.which == '39') {
$.dashboard.navigate('right');
}
if(event.which == '37') {
$.dashboard.navigate('left');
}
if(event.which == '49') {
$.dashboard.position('init');
}
if(event.which == '50') {
$.dashboard.position('middle');
}
if(event.which == '51') {
$.dashboard.position('end');
}
if(event.which == '77') {
$.dashboard.toggle();
}
});
}
});
$(".dashboard_panels > div").dashboard({
point : 'end'
});
$.dashboard.create();