How do I replace the default action of Tab Key to move to next HTML textbox with my own JavaScript function

Take this HTML code, if you place your cursor on the 1st text-box, and then press Tab Key. The cursor will automatically jump to the 2nd text-box.

Box1:
<textarea id='box' cols='60' rows='10'></textarea>

Box2:
<textarea id='box' cols='60' rows='10'></textarea>

I need to replace this default action of switching to the next textbox with execution of JavaScript function I’ve defined. Let’s say: instead of switching textboxes execute function that writes ‘a’ on the the 1st text-box upon pressing Tab inside the box.

Any idea how I can make this happen?