Convert text to "preview view" as you type?

Maybe with javascript? Could catch the user hitting “bold”, and run a function to make the text in the window bold. I’m not sure that would work, but it seems possible.