I have tried using a textarea for the last three days but i want the user to be able to change the font styles while typing it is impossible to have two conflicting styles in a textarea
Correct. I've looked at this in wanting to write a good code editor in JS. I love JS but have concluded that it can't be done. To have decent keyboard sensitivity, you have to use a textarea, not a more generic element. Textareas, however, have limits such as the one you noted.
Try a div and listen for keys up or down. Test arrow keys, Insert, Delete and whatever elese you care about. Let us know if you can get your job done. I just discarded the idea of doing keyboard shortcuts in an app because I couldn't get the shortcuts past the browser's listening for, and not passing on, their own shortcuts.
One more gotcha. JS strings are immutable. String += char is going to create a new string. Slow. Pushing new chars onto an array of char will be a lot faster.
So what I can tell you is to look for range selection as I said in other two threads. If you want to see an example for textarea, look how tinyMCE (WYSIWYG editor) does with their code. It does what you are looking for in text area. Though, you need to understand it before you utilize it to the way you want.
Hi, I have done this before, writing a text on a diva.. wow, it's really cool. So how would you do that? First, you must have a div element and a form with an input type text. You must set the width and the height of the div element to wrap up the text element. You must set the border of the text box to 0 and it's width to 1px.