Trigger OK button by pressing "Enter" (instead of clicking on it)

Where is my mistake?

I'd like to trigger OK button by pressing "Enter" (instead of clicking on it)

<div class="buttonbar">
				<button name="Cancel" type="button" onclick="window.KeyboardMaestro.Cancel('Cancel')">Cancel</button> 
				<button name="OK" type="submit" id="submit" onclick="window.KeyboardMaestro.Submit('OK')">OK</button>
    					.addEventListener("keyup", function(event) {
    					if (event.keyCode === 13) {

						function buttonCode()
  						alert("Button code executed.");

This would probably have more chance of getting a good answer on a DOM scripting forum since it doesn't seem to have anything to do with Keyboard Maestro.

Thanks, I'll look into it.

1 Like

Oh, if you look at one of my macroapps that uses a Custom HTML Prompt (like Mirror Mirror), you'll see the JS I used to trigger various keys, including Enter and Escape.

Thanks, I'll check it out!