How to prevent FF web connection from closing on ESC

There is a known bug where Firefox closes an open web socket connection when the user presses the ESC button. Is there any workaround or little jQuery code that can help me prevent this? I thought to start connecting a new web connection every time the current connection is closed, but this seems a bit dangerous.

+6
source share
1 answer

See https://bugzilla.mozilla.org/show_bug.cgi?id=676881 for a discussion of this issue and a partial fix. The following snippet executed after the page loads works for me:

$(window).keydown(function(event) { // check for escape key if (event.which == 27) { // the following seems to fix the symptom but only in case the document has the focus event.preventDefault(); } }); 
+7
source

Source: https://habr.com/ru/post/922160/


All Articles