Format for Accessing Button Click Events via Keyboard Shortcuts

I have a series of buttons that all use the same JS query switch statement to populate a table with a value based on the button clicked.

In addition to this I want to set keyboard shortcuts to trigger these button click events. I have searched high and low for the proper formatting to no success.

How do I programmatically trigger the button click events from within the shortcut menu? I feel like this should be easy but having troubles...

image

image

Switch statement that is inside each of the button click event handlers:

switch(triggeredById){ //gets name of component triggering the event
  case 'btn_approve': 
    tempState.setIn(["reviewed",table_poi.selectedRow.index],"approved");
    break;
  case 'btn_deny': 
    tempState.setIn(["reviewed",table_poi.selectedRow.index],"denied");
    break;
  case 'btn_poi_exception': 
    tempState.setIn(["reviewed",table_poi.selectedRow.index],"exception");
    break;
  case 'btn_roads': 
    tempState.setIn(["reviewed",table_poi.selectedRow.index],"roads");
    break;
  case 'btn_badgeom': 
    tempState.setIn(["reviewed",table_poi.selectedRow.index],"geometry");
    break;
  case 'btn_incorrect': 
    tempState.setIn(["reviewed",table_poi.selectedRow.index],"incorrect");
    break;
  case 'btn_multiple': 
    tempState.setIn(["reviewed",table_poi.selectedRow.index],"multiple");
}

table_poi.selectRow(table_poi.selectedRow.index + 1);
 



Hey @nels5722!

We have an open request for being able to trigger button clicks with keyboard shortcuts and we can let you know here when it's included.

In the meantime, one idea is to trigger your script directly and override triggeredById using additionalScope:

{{ yourScriptQuery.trigger({ additionalScope: {triggeredById: "btn_approve"} }) }}

Could that work?

1 Like

Thanks for the reply, @Kabirdas . I will give this a shot and get back to you tomorrow.

@Kabirdas

I've tested your idea with using additionalScope and it works! Thanks so much.