T-7000 adhesive in a tube. this is the black version, just a tiny amount around the edge, turn the phone over and weight with a heavy book while the adhesive sets up.
the keyboard is held on the side by several clips. if one gently flexes/curves the keyboard upward a bit in the middle (by the front retaining prongs) this will pull the keyboard sides away and they will gently 'pop' out from under the side clips.