Skip to content

Commit 3aed015

Browse files
committed
Fixed an issue where Backspace, Enter, etc input keys when pressed, are getting written as text in PSQL tool. #6968
1 parent ff1d9e2 commit 3aed015

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

web/pgadmin/tools/psql/static/js/components/PsqlComponent.jsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,21 @@ function psql_terminal_io(term, socket, platform, pgAdmin) {
111111
});
112112

113113
term.onKey(function (ev) {
114-
socket.emit('socket_input', {'input': ev.domEvent.key, 'key_name': ev.domEvent.code});
114+
socket.emit('socket_input', checkInputKey(ev));
115115
});
116116
}
117117

118+
/* This function will check input key from the mentioned excludedKeys and if those
119+
keys are pressed, it will return event's key else it will return event's domEvent key */
120+
function checkInputKey(ev){
121+
const excludedKeys = ['Enter','Escape', 'Tab', 'Backspace', 'ArrowUp','ArrowDown', 'ArrowLeft', 'ArrowRight'];
122+
if(excludedKeys.includes(ev.domEvent.key)) {
123+
return {'input': ev.key, 'key_name': ev.domEvent.code};
124+
} else {
125+
return {'input': ev.domEvent.key, 'key_name': ev.domEvent.code};
126+
}
127+
}
128+
118129
function psql_Addon(term) {
119130
const fitAddon = new FitAddon();
120131
term.loadAddon(fitAddon);

0 commit comments

Comments
 (0)