Skip to content

Fix keyboard trap #277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions site/js/jquery.console.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@
36: moveToStart,
// return
13: commandTrigger,
// tab
// alt
18: doNothing,
// tab
9: doComplete
};
var ctrlCodes = {
// C-a
Expand Down Expand Up @@ -198,7 +196,6 @@
};

var focusConsole = function() {
inner.addClass('jquery-console-focus');
typer.focus();
};

Expand Down Expand Up @@ -283,6 +280,12 @@
inner.addClass('jquery-console-nofocus');
});

// Handle receiving focus, helpful now that we can use keyboard to navigate to element
typer.focus(function() {
inner.removeClass('jquery-console-nofocus');
inner.addClass('jquery-console-focus');
})

////////////////////////////////////////////////////////////////////////
// Bind to the paste event of the input box so we know when we
// get pasted data
Expand Down Expand Up @@ -320,6 +323,12 @@
cancelExecution();
return false;
}
// Handle tab key
if (keyCode == 9) {
typer.blur();
return true
}

if (acceptInput) {
if (e.shiftKey && keyCode in shiftCodes) {
cancelKeyPress = keyCode;
Expand Down