Skip to content

Instantly share code, notes, and snippets.

@nikjft
Last active January 8, 2017 13:07
Show Gist options
  • Save nikjft/0646c829de63f4c158b32846ca35b707 to your computer and use it in GitHub Desktop.
Save nikjft/0646c829de63f4c158b32846ca35b707 to your computer and use it in GitHub Desktop.
JS routine to give Keyboard Maestro custom HTML prompts a timeout function. The timeout is automatically paused as soon as a key in pressed in a text input field so that it won't time out while someone's typing.
<script>
var timeout;
function KMInit() {
var dialogTimeout = 10000
timeout = setTimeout(function(){ window.KeyboardMaestro.Submit('Timeout'); }, dialogTimeout);
$('input[type=text]').keypress(function() {
console.log('Clearing timeout');
clearTimeout(timeout);
});
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment