How does an electroscope detect an electric charge on an object?

The gold leaves move apart.