Is it possible to write a plugin to replace text as it is being edited?

Something like the below? I would like to type Sinhalese.