Skip to content

Commit

Permalink
Fixed an issue where Backspace, Enter, etc input keys when pressed, a…
Browse files Browse the repository at this point in the history
…re getting written as text in PSQL tool. pgadmin-org#6968
  • Loading branch information
anilsahoo20 committed Jan 3, 2025
1 parent ff1d9e2 commit 3aed015
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion web/pgadmin/tools/psql/static/js/components/PsqlComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,21 @@ function psql_terminal_io(term, socket, platform, pgAdmin) {
});

term.onKey(function (ev) {
socket.emit('socket_input', {'input': ev.domEvent.key, 'key_name': ev.domEvent.code});
socket.emit('socket_input', checkInputKey(ev));
});
}

/* This function will check input key from the mentioned excludedKeys and if those
keys are pressed, it will return event's key else it will return event's domEvent key */
function checkInputKey(ev){
const excludedKeys = ['Enter','Escape', 'Tab', 'Backspace', 'ArrowUp','ArrowDown', 'ArrowLeft', 'ArrowRight'];
if(excludedKeys.includes(ev.domEvent.key)) {
return {'input': ev.key, 'key_name': ev.domEvent.code};
} else {
return {'input': ev.domEvent.key, 'key_name': ev.domEvent.code};
}
}

function psql_Addon(term) {
const fitAddon = new FitAddon();
term.loadAddon(fitAddon);
Expand Down

0 comments on commit 3aed015

Please sign in to comment.