I've read an excellent question/answer here: Binding arrow keys in JS/jQuery
but now I have this problem: while I can use arrow keys to navigate through various selections on my site, I can no longer edit things in text boxes the way I am used to, because my arrows are not working the way I expect anymore.
i.e. one first page that gets loaded via AJAX, I can navigate my "selections" (i.e. images) via arrow keys. Then I save my selection (image), and go to the 2nd page that is also loaded via AJAX.
But, arrow bindings are still in effect, so when I try to use Right, Left, Home, End, PgUp, PgDn arrows to navigate the cursor in a text box, to for example, correct a misspelling, nothing happens because I have prevented the default behavior to avoid various page elements being shifted on page 1 .. .
Is there a way to solve this?
My Code:
Not sure it will help here .. and not sure how I can help you help me, but here goes:
On Page 1:
<script type="text/javascript">
/*************************************/
/* selection navigation via keyboard */
/*************************************/
$(document).keydown(function(e) {
switch(e.which)
{
case 37: $("#selectPrevious").click();break;
case 39: $("#selectNext").click();break;
case 33: $("#jump10Back").click();break;
case 34: $("#jump10Forward").click();break;
case 36: $("#jumpFirst").click();break;
case 35: $("#jumpLast").click();break;
default: return;
}
e.preventDefault();
});
</script>
and apparently this key assignment does not get erased later, as I navigate to page 2. I don't want binding to be in effect on page 2. To be clear .. there is a Main page that stays loaded at all times, and Page 1 gets loaded via AJAX, then it gets replaced by page 2 via AJAX.