[Vm-dev] [SqueakJS] keyboard handling

Bert Freudenberg bert at freudenbergs.de
Mon Jan 4 20:51:25 UTC 2016


On 03.01.2016, at 14:32, Nicolai Hess <nicolaihess at gmail.com> wrote:
> 
> Hi Bert,
> 
> following observation:
> 
> in squeak.js,     
>     document.onkeypress = function(evt) {
>         if (!display.vm) return true;
>         // check for ctrl-x/c/v/r
>         if (/[CXVR]/.test(String.fromCharCode(evt.charCode + 64)))
> 
> this test never holds (at least not with firefox on windows).
> The charCode is always the same, regardless whether ctrl-key is pressed or not, so it always handles those
> shortcuts as squeak-shortcuts (ctrl+v is handled as "paste author initials", not as "paste text to browser window")
> (this is not an issue for chrome, because it does not use keypress, but the keydown events for cut&paste)
> 
> changing this to
> 
>         if (evt.ctrlKey && /[cxvr]/.test(String.fromCharCode(evt.charCode)))
> makes it working.
> 
> another issue is, that in firefox on windows, the "paste event" is never fired for non-editable htmlelements (it works for textareas and inputfields).
> But we can make the whole document "editable" with
> document.body.contentEditable = true
> (maybe it is enough to do this for the canvas elemement).
> 
> with this changes, copy , cut & paste are working in firefox (only tested on windows).

We may have to make this browser-dependent :(

If we make the canvas content-editable then on iOS the browser will zoom into the canvas as soon as you tap it … which OTOH may not be worse than what we have now (but I do remember some problem which led me to disabling it again).

Fabio started working on real keyboard support for touch devices but it’s not finished yet, see https://github.com/bertfreudenberg/SqueakJS/pull/42

- Bert -



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4115 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20160104/ef110fba/smime.bin


More information about the Vm-dev mailing list