jQuery UI Tabs has this βfunctionβ, where if I press the up / left or right / right arrows, it switches tabs and loads this tab.
Typically, for horizontal tabs, users are more familiar with the fact that the up and down keys scroll the page and move the tabs. Is it possible to disable tab navigation only for up and down keys?
UPDATE
Based on Konstantin's suggestion, I tried the following code. It blocks the event when I press the up or down button right after clicking the binding tab. If I press another key, like the left / right keys, and then press the up / down keys again. It logs an event, but does not seem to stop propagating. Can an event fire from another element? Here is my code:
$('#tabs').keydown(function (event) { console.log("in tabs"); if (event.keyCode == 40 || event.keyCode == 38) { event.stopPropagation(); event.preventDefault(); return false; }; }); $('.ui-tabs-anchor').keydown(function (event) { console.log("in ui tabs anchor"); if (event.keyCode == 40 || event.keyCode == 38) { event.stopPropagation(); event.preventDefault(); return false; }; }); $('.ui-tabs-nav').keydown(function (event) { console.log("in ui tabs nav"); if (event.keyCode == 40 || event.keyCode == 38) { event.stopPropagation(); event.preventDefault(); return false; }; });
source share