How to make Textarea submit form when hitting enter in Custom HTML prompt

Hi all - My coding isn't the best and I've been trying to adapt HTML keydown Event Listener - #10 by martin so that when I press ENTER in the text area field the form submits.

Unfortunately it doesn't work, here's the HTML:


	<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
	<meta content="en-us" http-equiv="Content-Language" />
	<link rel="stylesheet" href="">

	<style type="text/css">
		body {
			background-color: black;
			font-family: "Avenir Next";
			color: #fff;
			overflow: hidden;

		.buttonDiv {
			padding-top: 10px;
			display: none;

		section {
			width: 100%;
			margin: 2% 0% 0 1%;

		textarea {
			background: black;
			padding: 0 0 238px 0;
			color: #fff;
			border: none;
			line-height: 1em;

			width: 93%;
			font-size: 1.3em;
			vertical-align: middle;

		/* hide border when input selected */
		textarea:focus, input:focus{
			outline: none;

		function KMInit() {
			window.addEventListener("keydown", function (e) {
				if (e.keyCode == 13) {

		function submit(event) {
		function submitWindow(event) {

		function cancelWindow(event) {



<body data-kmwindow="SCREEN(Main,Left,20%),SCREEN(Main,Top,20%),750,300">

		<form action="#" method="post" value="">

<textarea rows="2" cols="20" autofocus="" name="NAMEOFQuery" wrap="hard" id="subject" class="subjectField" onkeydown="if (event.keyCode == 13) { this.form.submit(); return false; }" ></textarea>

			<!-- ========== BUTTONS ========= -->
			<div class="buttonDiv">
				<button class="btnDefault" name="Save" type="submit" title="Press RETURN to submit"
				<button class="btnCancel" name="Cancel" type="button" title="Press ESC to cancel"
					onclick="cancelWindow('Cancel');">Cancel</button> </div>



Any thoughts on how to fix? Appreciate any and all help, thanks!

The trick is:

				if (e.keyCode == 13) {
  			              return false;

but I also used a local variable so the contents does not persist. And I deleted a few unused subroutines and buttons.

Without the window.KeyboardMaestro.Submit('OK'); the form variable isn't passed to Keyboard Maestro.

Textarea Blurb.kmmacros (3.5 KB)

1 Like