Record the sound of the stylus sliding in and out, and use those audio fingerprints so the system will match those triggers to the events you want.
Just buy a spare stylus. It's easier, quicker and maybe even cheaper.