Javascript, WebView, and arrow keys.

by Ken Perry » Fri, 10 Sep 2010 00:22:12 GMT


Sponsored Links
 The following question has to do with Froyo 2.2 sdk 8 running on an
emulator.

 

 I am injecting Javascript  into a web page and in the WebView activity I
get 19, 20, 21, and 22 for key codes for arrow keys.  At the Javascript
level all four arrow key values in a keydown handler come in as zero.  The
following is the java script code I am using to set the handler and to get
the keyValue.

 

window.addEventListener('keydown', keyDownHandler, true); 

 

function keyDownHandler(evt){

var keyCode=evt.keyCode;

myLog(keyCode);

}

 

 

I will note that keys like enter come in correct for example I get 13 for
enter.  I also will note that if I press shift and then an arrow key I get
16 for all 4 arrow keys instead of 0.  myLog function takes a String but the
following works 

 

If (keyCode==0){

myLog("arrow key");

}

 

So the value is coming in as zero is there some way I can fix this.  If
someone has time I have a pretty simple example of this problem I could
probably zip up as an eclipse project.

 

Thanks,

 

Ken

  

--



Other Threads

1. Google analytics install referrer problem

I needed to track install information, so i used
com.android.vending.INSTALL_REFERRER intent for google
analytics:
http://code.google.com/mobile/analytics/docs/android/

I have put that intent into manifest as following:

<receiver android:name="com.mycompany.MyReceiver"
android:exported="true">
  <intent-filter>
    <action android:name="com.android.vending.INSTALL_REFERRER" />
  </intent-filter>
</receiver>


Inside MyReceiver class, i've implemented:

        public void onReceive(Context context, Intent intent) {
            String referrer =
URLDecoder.decode(intent.getStringExtra("referrer"));
            Log.d(TAG, referrer);

            com.google.android.apps.analytics.AnalyticsReceiver
receiver = new com.google.android.apps.analytics.AnalyticsReceiver();
            receiver.onReceive(context, intent);
         }

Then i installed app using generated at
http://code.google.com/mobile/analytics/docs/android/#android-market-tracking
url, and got this in log:

DEBUG/TestApplication(31977):
utm_source=androidmarket&utm_medium=device&utm_campaign=search&utm_term=pname:com.mycompany.test.market&rowindex=0&hl=en&correctedQuery=
WARN/googleanalytics(31532): Badly formatted referrer missing
campaign, name or source
WARN/googleanalytics(31532): Badly formatted referrer, ignored

So, instead of referral data that was given at url generation, i've
got data which looks like i was searching for my app at Market

Does anyone have this kind of trouble, or knows how to help?




-- 

2. You are invited to join Talk2Droid beta test

Hi, folks,
     We are pleased to introduce our new application - Talk2Droid,
which  allows you to remote access your Android phone right from Gmail
web page on your PC. While you are sitting in front a PC, it provides
you  a much more convenient way to do task like  reading incoming text
messages, sending text messages, checking missed calls, or looking up
phone address book, without bother to pull out your phone from your
pocket.
     Search talk2droid in AndroidMarket and follow the on-screen
instructions to activate an account in less than 20 seconds. Have fun.

Regards.

-- 

3. Linkify

4. Cannot Get to My Application in Market as a Developer

5. HTC Development Phone 1

6. Kernel Crash :

7. background and resize option