svnlabs / google-caja

Automatically exported from code.google.com/p/google-caja
0 stars 1 forks source link

onkeypress not working #1937

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
is there any possibility of allowing keypress or keydown to work with caja?

I'm making an app with apps script HTMLService and want to be able to have a 
keyboard shortcut

Original issue reported on code.google.com by jsc...@gmail.com on 10 Sep 2014 at 2:08

GoogleCodeExporter commented 9 years ago
Key events should work fine _except_ on the document itself because there are 
issues with making it possible to focus there. You should be able to use them 
on any form field, or any element made focusable using tabindex.

Simple example to test with:
<div onkeypress="this.textContent += ' '  + event.keyCode" tabindex="0">
    Click me and type
</div>​​

Original comment by kpreid@google.com on 10 Sep 2014 at 4:42

GoogleCodeExporter commented 9 years ago
Thank you very much. Do you know if it is possible to then focus that element 
on page load so it works automatically? I can't seem to get this example to 
work:

https://caja.appspot.com/#http://pastebay.net/pastebay.php?dl=1492607

Original comment by jsc...@gmail.com on 13 Sep 2014 at 11:08

GoogleCodeExporter commented 9 years ago
No. Caja specifically does not allow guest content to steal focus from the host 
page, because that could be abused (not in the Apps Script case, I suppose, but 
it's a generic policy at the moment). However, you can use .focus() in reaction 
to any user event (e.g. a click on any element or the virtual document).

Original comment by kpreid@google.com on 15 Sep 2014 at 4:26