From abcb5f883086e64e993b9a6712321a79100ae042 Mon Sep 17 00:00:00 2001 From: Anil Sahoo Date: Wed, 14 May 2025 13:46:16 +0530 Subject: [PATCH] Fixed an issue where the options key was not working as expected in the PSQL tool. #6968 --- .../psql/static/js/components/PsqlComponent.jsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/web/pgadmin/tools/psql/static/js/components/PsqlComponent.jsx b/web/pgadmin/tools/psql/static/js/components/PsqlComponent.jsx index 3fd513a42..5d1918800 100644 --- a/web/pgadmin/tools/psql/static/js/components/PsqlComponent.jsx +++ b/web/pgadmin/tools/psql/static/js/components/PsqlComponent.jsx @@ -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}); }); }