Firefox ESC breaks socket connections

839 views
Skip to first unread message

itsatony

unread,
Oct 23, 2011, 7:59:30 AM10/23/11
to Socket.IO
I encountered a simple yet ux-killing problem: whenever a user hits
ESC in firefox all socket connections are broken. I tried catching the
keyup event and doing event.preventDefault(), but that doesn't help
either.
Does anybody know a way around that?

Jason Delaney

unread,
Oct 23, 2011, 3:15:21 PM10/23/11
to sock...@googlegroups.com
Using jQuery I use this:

$(document).ready(function(){
$(this).keypress(function(e){
        if(e.keyCode == 27){
            return false;
        }
    });
});

Sanford Whiteman

unread,
Oct 23, 2011, 5:14:53 PM10/23/11
to sock...@googlegroups.com
Subverting the user's expectation of stopping net traffic seems like a miserable UX choice. Sometimes you just have to endure these events and let them follow through. Pop up a nice, visible slider that tells them they just dropped the socket, sure. Stopping them from doing it, ugh!

-- Sandy

Jason Delaney

unread,
Oct 24, 2011, 12:02:27 AM10/24/11
to sock...@googlegroups.com
You know, there are times when you need to just let the user have the choice, and I agree that that is in most cases the way to go, especially for privacy. However, at least in my scenario, there would be no reason for the user to drop their connection. Socket based chat, if they want to drop the connection then put a pause button, or something similar (like I have done). I think having the ESC button have control over that in un-needed especially since FF is the only browser that does it. It would cause more harm than good.

-Jason

Sanford Whiteman

unread,
Oct 24, 2011, 12:20:50 AM10/24/11
to Jason Delaney
> However, at least in my scenario, there would be no reason for the
> user to drop their connection. Socket based chat, if they want to
> drop the connection then put a pause button, or something similar
> (like I have done).

But would you do the same thing on the main page or an iframe if you
could: trap the Escape key and make them _use_ the page to _stop_ the
page?

Longtime FF power users have to be used to this working. They may be
deliberately using the Esc key to drop the connection -- this is a lot
more likely to happen on-purpose with persistent websocket
connections, or with XHR long-polling, than it might have been to
vainly try to stop, say, a single XHR that ran on domready.

Dunno, I can see both sides, but disabling it seems like the wrong
route.

-- S.


Jason Delaney

unread,
Oct 24, 2011, 12:30:58 AM10/24/11
to sock...@googlegroups.com
Well, I see where you are coming from. I guess it would depend on the application. In my app there are clear ways to disconnect if needed to (pause button). I could see far more cases where a user would accidentally hit the ESC and not know they disconnected. Maybe the best solution would be to have the ESC key trigger that "pause" event rather than just cutting the connection.

So rather than disabling the ESC itsatony, you could have it trigger an event (like the pause button in my case) just so that the user is aware that he/she has disconnected, and has the option to re-connect as well.

-Jason
Reply all
Reply to author
Forward
0 new messages