Is there a good way, in JavaScript, to recognize pressing the up arrow key when the cursor is on the first line of a text area?
Imagine that I want to mimic the behaviour of a terminal, where pressing up will cycle back through previously entered commands, but only if the cursor is on the top line of a potentially multi-line command.