How to Record Screen as GIF and Show Visualized Keystrokes

How to record the screen as a gif, and how to show keystrokes while typing during recording.