Three things...

in
Subscribe to Three things... 2 posts, 2 voices



DaveJamesMiller User

Useful script - with a few very minor issues:

1. The new line is inserted as well as the form being submitted
2. There is no way to put a new line in on the rare occasions you want to
3. If you press enter straight away, you get a blank screen

I believe this fixes all of these:

var statusElem = document.getElementById('status');
statusElem.addEventListener('keypress', function(evt) {
  if(evt.keyCode == evt.DOM_VK_RETURN && !evt.shiftKey) { // Hold shift to put in a new line
    if(statusElem.value != "") // Refuse to submit empty text
      statusElem.form.submit();
    evt.preventDefault(); // Don't insert new line
  }
}, false);

 
Ziru Script's Author

Hi DaveJamesMiller,

Thanks for the fixes. I've incorporated those into the latest version.

Ziru

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel