Using bcbhtml : First add html.cpp to your project and include "html.h":
#include "html.h"
define document variable in global scope:
THTMLDocument document;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
WebBrowser1->Navigate("about:<div contenteditable=true>Type here</div>"); // example editable region
}
void __fastcall TForm1::WebBrowser1DocumentComplete(TObject *ASender, const IDispatch *pDisp,
const OleVariant &URL)
{
document.documentFromVariant(WebBrowser1->Document);
document.onkeydown = &onkeydown;
}
void TForm1::onkeydown()
{
EventObj event = document.parentWindow.event;
if(event.keyCode == VK_RETURN)
{
document.selection.createRange().pasteHTML("<P> </P>"); // You can put every html you like per every key code
event.returnValue = false; // blocks default html which will be generated
}
}
You can download this great wrapper (bcbhtml) from here.