What causes static electricity when you touch a doorknob?
When you walk across a carpet, friction between your shoes and the carpet transfers electrons from the carpet to your body, giving you a net negative charge. Your body accumulates this excess charge as you move. When you then reach for a metal doorknob, which is a conductor connected to a grounded surface, the built-up electrons rapidly discharge through the brief spark you see and feel. Metal doorknobs are particularly prone to causing this because metal conducts electricity easily, allowing the charge to equalize almost instantly rather than slowly bleeding off. Dry air worsens the effect because humid air allows charge to dissipate gradually from your body before it can build up to noticeable levels.