Help needed in dart code

240 views
Skip to first unread message

saransh kataria

unread,
Apr 21, 2012, 2:18:03 AM4/21/12
to global-dar...@googlegroups.com

How to get the key pressed at run time on input type element?

Seth Ladd

unread,
Apr 21, 2012, 2:38:13 AM4/21/12
to Global Dart Hackathon on behalf of saransh kataria
element.on.keyPress.add((e) => ... );

On Fri, Apr 20, 2012 at 11:18 PM, Global Dart Hackathon on behalf of saransh kataria <global-dar...@googlegroups.com> wrote:

How to get the key pressed at run time on input type element?

--
You received this message because you are subscribed to the Google Groups "Global Dart Hackathon" group.
To view this discussion on the web visit https://groups.google.com/d/msg/global-dart-hackathon/-/pkY4_yjJasIJ.
To post to this group, send email to global-dar...@googlegroups.com.
To unsubscribe from this group, send email to global-dart-hack...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/global-dart-hackathon?hl=en.

saransh kataria

unread,
Apr 21, 2012, 5:32:58 AM4/21/12
to Global Dart Hackathon
i tried that, but the keyPress does not tell which key was pressed....
For instance, there is a keyUp() and keyDown() but no for left and right key presses...

Filip Hracek

unread,
Apr 21, 2012, 6:19:45 AM4/21/12
to Global Dart Hackathon on behalf of saransh kataria
try using e.charCode, which should hold the pressed key's charcode

element.on.keyPress.add((e) {
    if (e.charCode == 13) // Enter
        print("Enter pressed.");
});

Filip Hráček
Developer Relations // Google ČR

saransh kataria

unread,
Apr 21, 2012, 11:09:16 AM4/21/12
to Global Dart Hackathon on behalf of Filip Hracek
will try that but the solution that worked for me was:
document.on.keyDown.add((Event e){
  KeyboardEvent ke=e;
  //print(ke.keyIdentifier);
  if (ke.keyIdentifier=="U+0061" ||ke.keyIdentifier=="U+0041")
{}
}
 
});
Hope this helps some1 else :)

Patrik Gmitter

unread,
Nov 5, 2012, 4:17:46 PM11/5/12
to global-dar...@googlegroups.com
window.on.keyUp.add( (KeyboardEvent e) {
  
   if (e.keyCode == 27) // 27 for ESC, 13 for ENTER, etc..
   {
      // code
   }
              
});
Reply all
Reply to author
Forward
0 new messages