<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to send soft-keyboard input to a Phaser/JavaScript game  in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/How-to-send-soft-keyboard-input-to-a-Phaser-JavaScript-game/m-p/1098299#M67675</link>
    <description>&lt;P&gt;I managed to open soft-keyboard on android trough focusing an input element of type text. Yes I can type letters but i need those letters sent inside my Phaser/JavaScript game.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I used jQuery for the job and tried keypress() event but it doesn't seem to be working.&lt;/P&gt;

&lt;P&gt;What should I do in this case, how can i get those letters to JavaScript?&lt;/P&gt;

&lt;P&gt;Some of my code:&lt;/P&gt;

&lt;PRE class="brush:xml;"&gt;&amp;lt;input id="hiddenInput" type="text" name="hiddenInput" style="position:absolute; left:-1px; top: -1px; width:1px; height:1px; opacity:0"/&amp;gt;&lt;/PRE&gt;

&lt;PRE class="brush:jscript;"&gt;$("#hiddenInput").focus(); // i call this when I press the play button.

$("#hiddenInput").keypress(function (e) {
          this.logTextField.text += "hello "; // logTextField is of type Phaser.Text and it should show hello text once I press keyboard button
 }); // this event function is not called at all&lt;/PRE&gt;

&lt;P&gt;Also this is my android section in intelxdk.config.additions.xml&lt;/P&gt;

&lt;PRE class="brush:xml;"&gt;&amp;lt;platform name="android"&amp;gt;
    &amp;lt;!-- below requires the splash screen plugin --&amp;gt;
    &amp;lt;!-- docs: &lt;A href="https://github.com/apache/cordova-plugin-splashscreen" target="_blank"&gt;https://github.com/apache/cordova-plugin-splashscreen&lt;/A&gt; --&amp;gt;
    &amp;lt;preference name="SplashMaintainAspectRatio" value="false" /&amp;gt;
    &amp;lt;preference name="windowSoftInputMode" value="adjustPan" /&amp;gt;
    &amp;lt;preference name="configChanges" value="orientation|keyboardHidden" /&amp;gt;
    &amp;lt;preference name="loadUrlTimeoutValue" value="700000" /&amp;gt;
&amp;lt;/platform&amp;gt;&lt;/PRE&gt;

&lt;P&gt;Do these settings prevent something from happening or not?&lt;/P&gt;

&lt;P&gt;Note: I guess for regular from based cordova applications it is easier to set up the keyboard since you see the text fields, but what if you don't see it or should not see it?&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jun 2016 10:42:27 GMT</pubDate>
    <dc:creator>Vladimir_Z_</dc:creator>
    <dc:date>2016-06-16T10:42:27Z</dc:date>
    <item>
      <title>How to send soft-keyboard input to a Phaser/JavaScript game</title>
      <link>https://community.intel.com/t5/Software-Archive/How-to-send-soft-keyboard-input-to-a-Phaser-JavaScript-game/m-p/1098299#M67675</link>
      <description>&lt;P&gt;I managed to open soft-keyboard on android trough focusing an input element of type text. Yes I can type letters but i need those letters sent inside my Phaser/JavaScript game.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I used jQuery for the job and tried keypress() event but it doesn't seem to be working.&lt;/P&gt;

&lt;P&gt;What should I do in this case, how can i get those letters to JavaScript?&lt;/P&gt;

&lt;P&gt;Some of my code:&lt;/P&gt;

&lt;PRE class="brush:xml;"&gt;&amp;lt;input id="hiddenInput" type="text" name="hiddenInput" style="position:absolute; left:-1px; top: -1px; width:1px; height:1px; opacity:0"/&amp;gt;&lt;/PRE&gt;

&lt;PRE class="brush:jscript;"&gt;$("#hiddenInput").focus(); // i call this when I press the play button.

$("#hiddenInput").keypress(function (e) {
          this.logTextField.text += "hello "; // logTextField is of type Phaser.Text and it should show hello text once I press keyboard button
 }); // this event function is not called at all&lt;/PRE&gt;

&lt;P&gt;Also this is my android section in intelxdk.config.additions.xml&lt;/P&gt;

&lt;PRE class="brush:xml;"&gt;&amp;lt;platform name="android"&amp;gt;
    &amp;lt;!-- below requires the splash screen plugin --&amp;gt;
    &amp;lt;!-- docs: &lt;A href="https://github.com/apache/cordova-plugin-splashscreen" target="_blank"&gt;https://github.com/apache/cordova-plugin-splashscreen&lt;/A&gt; --&amp;gt;
    &amp;lt;preference name="SplashMaintainAspectRatio" value="false" /&amp;gt;
    &amp;lt;preference name="windowSoftInputMode" value="adjustPan" /&amp;gt;
    &amp;lt;preference name="configChanges" value="orientation|keyboardHidden" /&amp;gt;
    &amp;lt;preference name="loadUrlTimeoutValue" value="700000" /&amp;gt;
&amp;lt;/platform&amp;gt;&lt;/PRE&gt;

&lt;P&gt;Do these settings prevent something from happening or not?&lt;/P&gt;

&lt;P&gt;Note: I guess for regular from based cordova applications it is easier to set up the keyboard since you see the text fields, but what if you don't see it or should not see it?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 10:42:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/How-to-send-soft-keyboard-input-to-a-Phaser-JavaScript-game/m-p/1098299#M67675</guid>
      <dc:creator>Vladimir_Z_</dc:creator>
      <dc:date>2016-06-16T10:42:27Z</dc:date>
    </item>
    <item>
      <title>I changed the JS code above</title>
      <link>https://community.intel.com/t5/Software-Archive/How-to-send-soft-keyboard-input-to-a-Phaser-JavaScript-game/m-p/1098300#M67676</link>
      <description>&lt;P&gt;I changed the JS code above to this:&lt;/P&gt;

&lt;PRE class="brush:jscript;"&gt;$(document).keydown(function (e) {
         var val = $("#hiddenInput").val(),
             lastKey = val.charAt(val.length - 1),
             keyCode = val.charCodeAt(val.length - 1);

         SI.GameScreen.fillScreenTypingTextField($("#hiddenInput").val() + "\n ");
         SI.GameScreen.keypressHandler(lastKey, keyCode);
         $("#hiddenInput").val("");
 });&lt;/PRE&gt;

&lt;P&gt;I forgot to call keypressHandler() which accepts two parameters and is a custom made function, so now effectively I send data to my Phaser game.&lt;/P&gt;

&lt;P&gt;Still more to do. Now with keydown() event function the last letter is remembered again even when I press different button.&lt;/P&gt;

&lt;P&gt;Something like: Press "y" and then press "o", s&lt;SPAN style="font-family: Consolas, &amp;quot;Lucida Console&amp;quot;, Menlo, Monaco, &amp;quot;DejaVu Sans Mono&amp;quot;, monospace, sans-serif; font-size: 13.008px; line-height: 19.512px;"&gt;creenTypingTextField text field is again filled with "y" instead of "o".&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-family: Consolas, &amp;quot;Lucida Console&amp;quot;, Menlo, Monaco, &amp;quot;DejaVu Sans Mono&amp;quot;, monospace, sans-serif; font-size: 13.008px; line-height: 19.512px;"&gt;Need to investigate more.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 14:33:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/How-to-send-soft-keyboard-input-to-a-Phaser-JavaScript-game/m-p/1098300#M67676</guid>
      <dc:creator>Vladimir_Z_</dc:creator>
      <dc:date>2016-06-16T14:33:55Z</dc:date>
    </item>
    <item>
      <title>I recommend using the Debug</title>
      <link>https://community.intel.com/t5/Software-Archive/How-to-send-soft-keyboard-input-to-a-Phaser-JavaScript-game/m-p/1098301#M67677</link>
      <description>&lt;P&gt;I recommend using the Debug tab within Intel XDK. You will be able to investigate how your application's functions are processing the values provided via a USB connection to your Android device running your app.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 16:39:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/How-to-send-soft-keyboard-input-to-a-Phaser-JavaScript-game/m-p/1098301#M67677</guid>
      <dc:creator>Elroy_A_Intel</dc:creator>
      <dc:date>2016-06-16T16:39:15Z</dc:date>
    </item>
    <item>
      <title>Indeed the Debug mode enabled</title>
      <link>https://community.intel.com/t5/Software-Archive/How-to-send-soft-keyboard-input-to-a-Phaser-JavaScript-game/m-p/1098302#M67678</link>
      <description>&lt;P&gt;Indeed the Debug mode enabled me to find a solution:&lt;/P&gt;

&lt;PRE class="brush:jscript;"&gt;$(document).keyup(function (e) {
        var val = $("#hiddenInput").val(),
            lastKey = val.charAt(val.length - 1),
            keyCode = val.charCodeAt(val.length - 1);
            
        console.log("keyup: " + val + ", " + lastKey + ", " + keyCode);
        SI.GameScreen.keypressHandler(lastKey, keyCode);
});&lt;/PRE&gt;

&lt;P&gt;Instead of keydown() I use keyup() which sends the key code after you release the button.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 10:05:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/How-to-send-soft-keyboard-input-to-a-Phaser-JavaScript-game/m-p/1098302#M67678</guid>
      <dc:creator>Vladimir_Z_</dc:creator>
      <dc:date>2016-06-17T10:05:48Z</dc:date>
    </item>
  </channel>
</rss>

