[GIS] how to handle keyboard and click event

arcgis-javascript-apidojoevents

I am using ArcGIS JavaScript API and I want to show a message in console's log when I hold down "e" and click on a graphic drawn by a user.

this.map.graphics.on ("click", lang.hitch(this, function(evt){ 

  if (evt.keyCode == 69 ) {

      console.log("e clicked ");

  } 

}));

I know that e's code is 69 but I think evt.keyCode == 69 need some changes.

anybody can help me?

Best Answer

The click doesn't know about any letter key pressed. It only knows if Ctrl/Shift/Meta keys where pressed while you clicked.

For your use case, I think you would have to first listen for key-down and when the key pressed is e, then you listen for the click.

Related Question