Re: HTML+SVG+event listener
| Newsgroups | gmane.text.xml.svg.devel |
|---|---|
| Message-ID | <1841291454.636527365.1427129737450.JavaMail.root@zimbra59-e10.priv.proxad.net> |
Hi Jean-Claude, svg is not a focusable element, so it doesn't trigger keyboard events. Replace root with document and it should be fine. Yannick ----- Mail original ----- De: "Jean-Claude Moissinac [email protected] [svg-developers]" <svg-develop= [email protected]> =C3=80: [email protected] Envoy=C3=A9: Lundi 23 Mars 2015 17:07:46 Objet: [svg-developers] HTML+SVG+event listener I'm disturbed by the following small and simple code which seems correct to= me and if it works, must popup an alert each time a key is pressed; but it= doesn't work. Any comments? Why that code is false?=20 <html encoding=3D"UTF-8" >=20 <head>=20 <script type=3D"text/javascript">=20 function init()=20 {=20 var root =3D document.getElementById("root");=20 root.addEventListener("keydown", function(evt) { alert(evt); }, true);=20 }=20 </script>=20 </head>=20 <body onload=3D"init()">=20 <svg id=3D"root" xmlns=3D" http://www.w3.org/2000/svg " width=3D"100%" heig= ht=3D"100%">=20 <rect x=3D"0" y=3D"0" width=3D"100%" height=3D"100%" fill=3D"blue" />=20 </svg>=20 </body>=20 </html>=20 --=20 Jean-Claude Moissinac=20 ------------------------------------ Posted by: [email protected] ------------------------------------ ----- To unsubscribe send a message to: [email protected]= m -or- visit http://groups.yahoo.com/group/svg-developers and click "edit my membe= rship" ----