From 657bf08fb8c8ca01abe39a4078b198bf1e5b498a Mon Sep 17 00:00:00 2001 From: Anil Sahoo Date: Fri, 3 Jan 2025 12:22:24 +0530 Subject: [PATCH] Fixed an issue where keys like Backspace, Enter, and Input keys were shown as text in the PSQL tool. #6968 --- .../psql/static/js/components/PsqlComponent.jsx | 12 +++++++++++- 1 file changed, 11 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 b60130263d8..71c2ee15548 100644 --- a/web/pgadmin/tools/psql/static/js/components/PsqlComponent.jsx +++ b/web/pgadmin/tools/psql/static/js/components/PsqlComponent.jsx @@ -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);