How do pilots detect and respond to windshear while landing and taking off?
The most dangerous form of windshear for planes is the microburst. This is a downdraft that after it hits the ground spreads out in all directions. It is dangerous particularly for planes low to the ground (on takeoff and landing)

When a plane coming in for a landing approaches the microburst it will enter a headwind and see and increase of airspeed and lift, the inexperienced and unsuspecting pilot may then reduce engine power to slow down and keep himself aligned. After the plane passes through the burst it will enter a tailwind decreasing lift which may cause the plane to crash into the ground short of the runway. 

To prevent crashing the pilot would need to keep power and possibly abort the approach to wait out the burst.

Detecting windshear from the ground is done with doppler radars (TDWR) and multiple wind sensors (LLWAS) which can detect the changes in wind which will be relayed to pilots in accordance with regulations (3-1-8).

All turbine powered airplanes used in §121 operations, except for turbopropeller powered airplanes, must have a windshear detection system installed, this is detected in one of 2 ways, using the onboard weather radar (predictive) or using the wind sensors on the aircraft like the angle of attack and airspeed (reactive).