I'm pretty sure it happens outside of cmode too.. but yeah I can't try right now, but I recall having that happen before.
Outside of cmode is just annoying, in cmode could break break the run maybe? xD
And I guess you didn't fully understand what saith said... The function of those keys will change according to what you are doing in game, esc will exit from a menu, cancel the chat or activate the palette function is assigned to.
As you said it should not do any action besides cancelling chat but it still does, somehow is broken.