title: Is it possible to override the keydown repeat delay, in JavaScript?
body: <p>The objective is manually set a held key's "repeat rate".</p>
  
  <p>For example, when in a text box and pressing and holding the X key, I understand that there is <a href="http://unixpapa.com/js/key.html" rel="nofollow noreferrer">browser-specific ways of repeating the pressed character</a>.  In some, it pauses, then continuously triggers the pressed key.  In others, it doesn't repeat at all.  I want to mitigate this by forcing the pressed key to repeat at a specific interval, regardless of browser.</p>
  
  <p>Through research, I've come up with a timer-based attempt, but in Safari, it does not repeat the character.  I've got a menu system where holding down arrow scrolls through the list, but the translation animation and repeat rate don't like each other.</p>
  
  <pre><code>var repeating = false;
  var repeatRateTimer = null;
  
  $( document ).bind( 'keyup', function( input ) {
      if( repeatRateTimer != null )
      {
          clearTimeout( repeatRateTimer );
          repeatRateTimer = null;
      }
  
      repeating = false;
  } );
  
  $( document ).bind( 'keydown', function( input ) {
      input.preventDefault( );
  
      if( repeating == true )
      {
          if( repeatRateTimer != null )
          {
              clearTimeout( repeatRateTimer );
              repeatRateTimer = null;
          }
          else
          {
              repeatRateTimer = setTimeout( function( ){ repeating = false; }, 1000 );
          }
  
          return;
      }
      repeating = true;
  
      // ...keyboard logic
  } );
  </code></pre>
  
  <p>I may have botched this whole thing up...I tried to recreate a simplified version of <a href="https://stackoverflow.com/a/3691661/1028949">this SO post</a>.  However, I feel there <em>has</em> to be a better way of doing this.  Any thoughts?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>We can assume that the end-user hasn't set their OS keyboard repeat rate greater than the rate I want to use (1000ms).  If it is, then it should fall back to their repeat rate, since it won't keep triggering the key press event.  If it isn't (more likely since most people don't modify that), then we would be overriding that behavior to make it delay our specified period. </p>