It uses a real-time JavaScript editing framework that we're in the process of open sourcing: https://github.com/Khan/live-editor
A technical talk on the editor (a bit dated at this point, but most of the points still hold) can be found here: http://ejohn.org/blog/talk-khan-academy-computer-science/