Leonardo on OSX - not in sync when uploading

BTW, we expect the application (sketch) COM port to be different than the bootloader COM port. The upload process takes that into account (it waits for the sketch COM port to disappear and for any new COM to appear, assuming it's the bootloader). If you have better luck by forcing them to be the same, that sounds good to me. Just wanted to let you know that it's not necessarily a problem that they have different numbers.

And yes, my guess is that KEY_F4 is an int, and so print() tries to print its digits rather than sending it as a single key press. The write() function always tries to send a single key press (or a single byte, if you're using Serial).