First solution: Create .on('click') event handler to Raphael's container which will create a textarea on place of click. Style this textarea by CSS rules - absolute positioning to a place of click; set width-height; remove borders, make transparent background, to achieve an illusion that you're typing the text directly to Raphael's canvas. Then attach key listener to the textarea (listen "Enter" on "Ctrl+Enter" if you need Enter key for new line breaks). Enter key will create Raphael.Text element.Second solution: After click on canvas - create a hidden textarea (set CSS {position: absolute; left: -9999px} to hide it, don't use {display: none}). Also create Raphael.Text object on place of click. Then as you type in, text will add to hidden textarea - read its value on each keypress and update Raphael's text object.
貌似都不太理想,每次回车都要新增一个 Raphael.Text对象。