Fixed an issue where keys like Backspace, Enter, and Input keys were shown as text in the PSQL tool. #6968

This commit is contained in:
Anil Sahoo 2025-01-03 12:22:24 +05:30 committed by GitHub
parent ff1d9e20d1
commit 657bf08fb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -111,10 +111,20 @@ 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};
}
return {'input': ev.domEvent.key, 'key_name': ev.domEvent.code};
}
function psql_Addon(term) {
const fitAddon = new FitAddon();
term.loadAddon(fitAddon);