Skip to content

Commit

Permalink
arrows left/right in input
Browse files Browse the repository at this point in the history
  • Loading branch information
joknarf committed Dec 22, 2024
1 parent 946bd79 commit e37a1b7
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions pywebfs/pywebfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@
// keyboard navigation
document.addEventListener('keydown', function(event) {
if (event.key === 'Enter') return;
const focusedElement = document.activeElement;
if (document.activeElement.tagName === 'BODY') {
document.getElementById("search").focus();
Expand Down Expand Up @@ -473,23 +474,19 @@
}
return;
}
if (event.key === 'ArrowRight') {
event.preventDefault();
if (focusedElement.tagName === 'A') {
if (focusedElement.tagName === 'A') {
if (event.key === 'ArrowRight') {
event.preventDefault();
focusedElement.click();
return;
}
return;
}
if (event.key === 'ArrowLeft') {
event.preventDefault();
if (focusedElement.tagName === 'A') {
if (event.key === 'ArrowLeft') {
event.preventDefault();
window.history.back();
return;
}
return;
}
if (event.key != 'Enter') {
document.getElementById("search").focus();
}
document.getElementById("search").focus();
});
function dl(hr) {
Expand Down

0 comments on commit e37a1b7

Please sign in to comment.