#1976 JS and the fwt::Widgit#onKeyDown() Event

SlimerDude Wed 25 Jul 2012

If I add the following to a Widget (specifically a fwt::Canvas)

onKeyDown.add |Event event| {
  chr := event.keyChar.toChar
}

while everything is fine in Java, in JavaScript I get a sys::NullErr: Coerce to non-null as it seems the fwt::Event#keyChar is not set, even though fwt::Widget#onKeyDown says it should be.

andy Thu 26 Jul 2012

Event.keyChar is not very reliable in the browser. I recommend you use Event.key and use the built-in Key constants.

SlimerDude Thu 26 Jul 2012

Yeah, that's what I did. But if Event.keyChar is not set in JS, could it not be reflected in the docs?

Or maybe replace it with a Key.keyChar method which throws an sys::UnsupportedErr in JS?

Login or Signup to reply.