In my tests, the above traps the ESC key if it's pressed, but the real challenge here, is probably usage of autonumber for something it's probably not intended to.
If you search TT with keyword autonumber, I think you'll find that usage of autonumbers are not exactly encouraged by other members.
Some of the reasons for that, you are experiencing, others have to do with possible problems with concurrent users. To sum it up, I think there seems to be some kind of agreement that you should never use autonumbers when the number is supposed to have any business meaning.
I think you should look at other means of generating your unique number. Another member, MichalRed has a very good faq on the topic faq700-184. Sometimes generating the number using for instance DMax in the forms before update event might also be sufficient.
Roy-Vidar