Actually, here is another solution for those who need to go online. I couldn’t get the code above translated into JS. It doesn’t like core.Clock(). I tried a ton of other things, but could not get it to work. Then I accidentally found a discourse page asking about text entry (never came up when I was searching for text entry). That page sends you here:
On that pavlovia page is BOTH the python and the JS for text entry. It doesn’t include a cursor like the code above, but works just as well.