Dart language arrow keys event

Issue

i’m trying to develop a simple application in dart, and i want to catch the arrow keys press
event, i tried to add a onKeyPress event:

window.on.keyPress.add(myKeyDownEvent);

void myKeyDownEvent(Event event){
  query("#text").text = event.type.toString();  
}

It works with all keypress except arrow keys what is wrong?

Solution

There’s a issue on chrome for that with WontFix status. Comment 5 says :

This is done to match IE. keypress events are only supposed to fire for keys that insert
characters. Note that keydown/keyup do fire for arrow keys.

Using window.on.keyDown instead of window.on.keyPress works for me.

Answered By – Alexandre Ardhuin

Answer Checked By – Dawn Plyler (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *