title: Prevent default behavior in text input while pressing arrow up
body: <p>I’m working with basic HTML <code>&lt;input type="text"/&gt;</code> text field with a numeric value.</p>
  
  <p>I’m adding JavaScript event <code>keyup</code> to see when user presses arrow up key (<code>e.which == 38</code>) – then I increment the numeric value.</p>
  
  <p>The code works well, but there’s one thing that bugs me. Both Safari/Mac and Firefox/Mac move cursor at the very beginning when I’m pressing the arrow up key. This is a default behavior for every <code>&lt;input type="text"/&gt;</code> text field as far as I know and it makes sense.</p>
  
  <p>But this creates not a very aesthetic effect of cursor jumping back and forward (after value was altered).</p>
  
  <p>The jump at the beginning happens on <code>keydown</code> but even with this knowledge I’m not able to prevent it from occuring. I tried the following:</p>
  
  <pre><code>input.addEventListener('keydown', function(e) {
      e.preventDefault();
  }, false);
  </code></pre>
  
  <p>Putting <code>e.preventDefault()</code> in <code>keyup</code> event doesn’t help either.</p>
  
  <p>Is there any way to prevent cursor from moving?</p>