Well this will stop the backspace button at all times from navigating back:
$(document).keydown(function(e) {
if (e.keyCode === 8)
{
return false;
}
});
Now to figure out how to run this only when checkboxes are focused...
Edit:
The problem with figuring out if a checkbox has focus is that it only gets focus if it is tabbed to or actually set in code. If it is clicked it is checked but it actually does not focus (at least in chrome/safari). This all depends on how you set the focus.
Edit 2:
To make your checkbox have focus when it is clicked, just add this:
$('input[type=checkbox]').click(function() {
$(this).focus();
});
...so putting it all together, this would have the checkbox focus on click and stop the backspace button when a checkbox has focus (all inside $(document).ready function of course):
$(document).keydown(function(e) {
if (e.keyCode === 8 && $('input[type=checkbox]:focus').size() > 0)
{
return false;
}
});
$('input[type=checkbox]').click(function() {
$(this).focus();
});