Adding Keyboard Input (part 2)
Now that we have included the new keyboard input helper file, how do we access it? Well, Jerome Etienne designed his 'threex.keyboardstate.js' to work a lot like Three.js does, so we should feel comfortable using it. Open up our 'tempGame.js' file and add the following line near the top: var keyboard = new THREEx.KeyboardState(); That looks familiar doesn't it? There IS a small difference however in this variable declaration. Notice the small letter 'x' placed right after the word 'THREE' . This tells us that the variable 'keyboard' will be using the new THREEx library rather than the older THREE library that we have had since the beginning of our project. Other than that, it's identical in syntax, so we should feel right at home. The 'keyboard' object now holds all the properties and functionality designed by Jerome to aid us in scanning the player's keyboard for keypresses in real time. And since we want ...