F6 instead of up-arrow

For years, during which I've owned several Apple keyboards, I've experienced a well-documented (but ignored by Apple) problem where the up-arrow key sends the wrong signal. To be clear, this doesn't happen with the keyboard built into my Macbook Pro; only this particular brand of external keyboard.

The problem would appear for long periods then suddenly disappear, for no apparent reason, then reappear shortly later, and just as inexplicably. It caused me much grief while working in IDEs like IntelliJ and Eclipse. Until I switched to VIM. Ah, bliss.

Damned Apple keyboard! 😡

Anyway, today I was trying out the Swift REPL, as a way to learn Swift syntax. I pasted this into the REPL:

After I ran it, I wanted to make changes, naturally. So I hit the up arrow a few times and get this strangeness:

Argh!

The up arrow was sending F6 to the terminal (which appears as "7~") in addition to moving the cursor.

The workaround I landed on after some time googling and experimenting, was to configure my terminal emulator, iTerm2, to ignore F6.

Hurrah!

The bigger problem still exists, sure to raise its hoary, barnacled dome again. But for now, I live to fight another day. That's good enough. 🎈