Actually, you don't need to use any specific function, it's sufficient to specify the dir prop for the <input> element, for example:
dir
<input>
<input type="text" dir="rtl" />
In this case rtl is right-to-left, ltr would be left-to-right.
rtl
ltr