Segobiano Posted February 21, 2014 Share Posted February 21, 2014 I have not found an example on Phaser examples that takes text inputs from users. I know i can take key stroke but i want whole strings to be input by the users. So they can type in a word and strike the enter keyboard key to accept it in or something similar. Thanks Link to comment Share on other sites More sharing options...
Yotam Posted February 21, 2014 Share Posted February 21, 2014 // This function computes the ascii for the key if it's an upper- or lower-case letter. function mykeydownhandler( evt ) { // Skip it unless it's a-z. if( evt.which < "A".charCodeAt(0) || evt.which > "Z".charCodeAt(0) ) { console.log( "Not a letter: ", evt.which ); return; } var letter = String.fromCharCode( evt.which ); if( !evt.shiftKey ) letter = letter.toLowerCase(); console.log( letter ); } In your create() function: game.input.keyboard.addCallbacks( this, mykeydownhandler ); Link to comment Share on other sites More sharing options...
Recommended Posts