Using a conductive capacitor that is integrated as part of the pen, it connects to an electromagnetic field generated by an excitation coil in the digitizer.
The coil is suspended in an external magnetic field and the current running through it adjusted so that the attraction between the two magnets balances the gravitational force on the suspended mass.