codefrau / SqueakJS

A Squeak Smalltalk VM in Javascript
https://squeak.js.org
MIT License
365 stars 75 forks source link

Cannot type '@' on Windows+Chrome #24

Closed marceltaeumel closed 8 years ago

marceltaeumel commented 9 years ago

It's [Alt Gr] + [Q] for me under Windows 8.1.

marceltaeumel commented 9 years ago

Seems to emulate some other keyboard shortcut, which is related to auto-completion. Typing [m] + [@] writes 'minimalWidth:'. Not sure, which shortcut this is.

codefrau commented 9 years ago

Sounds like it generates Alt-Q which does auto-completion. Since I don't have a windows machine, I can't really debug this ... you would need to fix document.onkeydown / onkeypress / onkeyup in https://github.com/bertfreudenberg/SqueakJS/blob/master/squeak.js#L454

nicolaihess commented 8 years ago

With firefox on windows 10, AltGr + q for typing @ does not work as well. But I was able to fix this for firefox: ( you need to distinguish between "alt" or "ctrl" or "AltGr", that behaves like "alt+ctrl").

function recordModifiers(evt, display) { var alt = (evt.altKey && !evt.ctrlKey); var ctrl = (evt.ctrlKey && !evt.altKey); var modifiers = (evt.shiftKey ? Squeak.Keyboard_Shift : 0) + (ctrl ? Squeak.Keyboard_Ctrl : 0) + (alt || evt.metaKey ? Squeak.Keyboard_Cmd : 0); display.buttons = (display.buttons & ~Squeak.Keyboard_All) | modifiers; return modifiers; }

codefrau commented 8 years ago

Nice! I'd write it like this—should work the same, right?

function recordModifiers(evt, display) {
    var shiftPressed = evt.shiftKey,
        ctrlPressed = evt.ctrlKey && !evt.altKey,
        cmdPressed = evt.metaKey || (evt.altKey && !evt.ctrlKey),
        modifiers =
            (shiftPressed ? Squeak.Keyboard_Shift : 0) +
            (ctrlPressed ? Squeak.Keyboard_Ctrl : 0) +
            (cmdPressed ? Squeak.Keyboard_Cmd : 0);
    display.buttons = (display.buttons & ~Squeak.Keyboard_All) | modifiers;
    return modifiers;
}

Do you want to send a pull request (which would get you listed as a contributor), or do you want me to commit this?

nicolaihess commented 8 years ago

Ok, I made a pull request https://github.com/bertfreudenberg/SqueakJS/pull/47 this adds another change for making this work on chrome for windows too.