You need to tie an event handler in javascript to onkeypress event (not to use onkeyup or keydown because you'll lost characters if user press and holds a key).
In that you'll:
1) compare the length of your text field to a hidden field;
2) copy the final characters (determined by length difference) to the shadow field;
3) replace the textfield content with the "*" equal to previous length of the hidden field, plus that final characters;
4) set the selection range to the end of the textbox.
EDIT: Changed the function logic a bit so it'll even handle case or repetitive keypress or a paste action.