DMS2

onkeyup event anytime

Discussion created by DMS2 on Jan 23, 2014
I'm trying to capture the onkeyup event for the ESC key after a template is selected in the template picker, so that if a user decides he doesn't want to draw a feature when he has already selected a template just by pressing the ESC key the template will unselect with a drawToolbar. deactivate.
My code is similar to this sample.

Im using this code:
    var key_event_handle = dojo.isIE ? dojo.query('body')[0] : window;
    dojo.connect(key_event_handle, "onkeyup", function(key) {
      if (key.keyCode == dojo.keys.ESCAPE) { drawToolbar.deactivate();} //ESC = 27
    }); 


The onkeyup event is only captured after I've drawn a first point. Once I've done that if will work every time. What am I doing wrong?

Outcomes