Fixed an issue where the options key was not working as expected in the PSQL tool. #6968

pull/8753/head
Anil Sahoo 2025-05-14 13:46:16 +05:30 committed by GitHub
parent ebb4c9994f
commit abcb5f8830
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 1 deletions

View File

@ -111,7 +111,18 @@ function psql_terminal_io(term, socket, platform, pgAdmin) {
});
term.onKey(function (ev) {
socket.emit('socket_input', {'input': ev.key, 'key_name': ev.domEvent.code});
let key = ev.key;
/*
Using the Option/Alt key to type special characters (such as '\', '[', etc.) often does not register
the correct character in ev.key when using xterm.js. This is due to limitations in how browsers and
xterm.js handle modifier keys across platforms.
To address this, if the Alt/Option key is pressed and the key is a single character,
we use ev.domEvent.key, which more reliably represents the actual character intended by the user.
*/
if (ev.domEvent.altKey && ev.domEvent.key.length === 1){
key = ev.domEvent.key;
}
socket.emit('socket_input', {'input': key, 'key_name': ev.domEvent.code});
});
}