Skip to content

Commit abcb5f8

Browse files
authored
Fixed an issue where the options key was not working as expected in the PSQL tool. #6968
1 parent ebb4c99 commit abcb5f8

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

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

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

113113
term.onKey(function (ev) {
114-
socket.emit('socket_input', {'input': ev.key, 'key_name': ev.domEvent.code});
114+
let key = ev.key;
115+
/*
116+
Using the Option/Alt key to type special characters (such as '\', '[', etc.) often does not register
117+
the correct character in ev.key when using xterm.js. This is due to limitations in how browsers and
118+
xterm.js handle modifier keys across platforms.
119+
To address this, if the Alt/Option key is pressed and the key is a single character,
120+
we use ev.domEvent.key, which more reliably represents the actual character intended by the user.
121+
*/
122+
if (ev.domEvent.altKey && ev.domEvent.key.length === 1){
123+
key = ev.domEvent.key;
124+
}
125+
socket.emit('socket_input', {'input': key, 'key_name': ev.domEvent.code});
115126
});
116127
}
117128

0 commit comments

Comments
 (0)