Detecting when keystrokes reach a preset number

I want to use JavaScript to detect the number of times a key (for example, the A key) is pressed. Once it reaches a preset number (say 10 for this example), it will trigger two events:

  1. Change the background color of a cell in a table from white to black.
  2. A split-second (e.g., .01 second) later, submit the form on this page

I can’t have the user hit the ENTER key to submit the form, so the JavaScript script will need to do this.

Thank you very much for your help!