Helena J.
Helena J.

Reputation: 105

Change Input text as user types into preselected text

I am trying to recreate the effect in Hackertyper, http://hackertyper.com/ , where as soon as you start typing it triggers the output of preset text.

Could this code help at all? Detect all changes to a <input type="text"> (immediately) using JQuery

Upvotes: 0

Views: 116

Answers (1)

Jens A. Koch
Jens A. Koch

Reputation: 41776

Sure, it's basically event binding.

You could also take a look at the original source code to get inspired and see how its done: http://hackertyper.com/script.js

It's a main event loop bound to the keydown event (page start). Based on that event (the keydown) the pressed key is key.KeyCode, which you might use to add text depending on the key. The text is appended by $("#console").append(str); That's it.

Upvotes: 1

Related Questions