I would measure the time between two KeyReleased messages for same key instead, to avoid having it accidently triggered by automatic key repeat. Or alternatively measure time between a KeyReleased and the next KeyPressed message if you like to have it activated on key down.