The shock you feel when you touch an object after walking on carpet is static electricity. When you drag your feet across carpet on a dry day, electrons from the carpet get transferred to your body. If you then touch a piece of metal, such as a doorknob, the electrons jump to the metal and you’ll feel a shock.