4 ms·
Whenever I press "[" it actually inserts "8[" into the editor. I use Opera 10.5 and a German keyboard (on the German keyboard layout you get an "[" by pressing
by cx01 16y ago
Whenever I press "[" it actually inserts "8[" into the editor. I use Opera 10.5 and a German keyboard (on the German keyboard layout you get an "[" by pressing ALT+"8", if that's any help).
I think you might want to look at how Opera handles keydown and keypress events in Javascript. I had a similar problem working on my own project a few days ago.
- chrisdone 16y agoAh, I haven't tested with a German layout. I have OS X and Ubuntu available to test on. What operating system are you using? Indeed, I had to add some special support for Opera in places with the key codes. For example, it's impossible to tell, on Opera, when someone presses the End key and when they press, say, 'h', because Opera sends 'h' for both keys. (Or whatever letter.) Actually it is possible with some hackery but it is a pain!
- cx01 16y agoI'm on Win7. Actually I made a slight mistake on my original comment. You get "[" by pressing ALTGR+"8" not ALT+"8". Don't know if it makes a difference.
- chrisdone 16y agoOK, I'll try to get hold of a Win7 machine at work. Can't make any promises though! (Nearly everyone at my workplace uses Linux.) Hopefully a kind soul of German persuasion with JavaScript know-how and a penchant for Windows will come along and fix it.
- cx01 16y agoI noticed that Opera sends two keypress events when I press "[". The first event (that generates the erroneous "8") has e.altKey==true. So a simple solution might be to add the following to the keypress function "if(e.altKey) return;". I've tested this locally and it works for me, but don't know if it might interfere with other keyboard layouts.
- chrisdone 16y agoHmm. I think we can take the risk and if others complain we can deal with their layout too. Someone else also suggested ignoring e.altKey with this patch: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=25853#a25859 http://hpaste.org/fastcgi/hpaste.fcgi/view?id=25853#a25859 I will try applying this patch and let you know.
- chrisdone 16y agoOk, I applied the patch mentioned in the other post. Please try now and let me know if the issue still exists!
- cx01 16y agoWhen I go to tryhaskell.org, it still doesn't work. I believe the patch that you've mentioned only applies to when the user presses ALT+TAB, which won't help here. I'd suggest you either do "if(e.altKey)return;" or "if(e.altKey && e.ctrlKey)return;". Both work for me. EDIT: Hm, my suggested changes work in Opera, but they break Chrome... This is driving me crazy.