When you’re using Google Docs, you’re not actually typing into where you think you’re typing. You’re typing into a textarea in an iFrame off-screen, and through the postMessage API, those events are being sent to the “edit surface” that you see, which does stuff like draw your cursor. (Your cursor on Docs isn’t actually a cursor, it’s a 2px-wide div!)

James Somers: How I Reverse Engineered Google Docs To Play Back Any Document’s Keystrokes