Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 20:37, 6 March 2008.

How to interpret key events in WRT widgets?

From Forum Nokia Wiki


Compatibility: Web Runtime in S60 3rd Edition, Feature Pack 2

Contents

Browser engine differences

In general, different browser engines differ in key event codes visible to JavaScript level. S60 WRT widget text and input field components do not support all key events found in the other browser or widget environments.

S60 WRT specific APIs

S60 WRT API

widget.setNavigationEnabled(false);

disables navigation mode and allows your JavaScript code to collect also cursor key events.

Example

Following simple example let's you explore different key event values provided by S60 WRT:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <script type="text/javascript">		
			
      /*
       * attach key listeners
       */
      document.onkeypress = keyPress;
      document.onkeyup = keyUp;
      document.onkeydown = keyDown;
 
      /*
       * disable cursor navigation - otherwise cursor 
       * key events are not received by keypress callbacks
       */
      widget.setNavigationEnabled(false);
			
      /*
       * show keyCode and charCode.
       */
      function keyPress(event) {
	document.getElementById('keypressField').innerHTML = event.keyCode + " / " + 
event.charCode;
      }
      
      function keyDown(event) {
	document.getElementById('keydownField').innerHTML = event.keyCode + " / " + 
event.charCode;
      }
			
      function keyUp(event) {
	document.getElementById('keyupField').innerHTML = event.keyCode + " / " +
event.charCode;
      }
    </script>
		
    </head>
  <body>
    keyCode / charCode:
    
    <div>
      KeyPress: 
      <div id="keypressField"></div>
    </div>
    
    <div>
      Keydown: 
      <div id="keydownField"></div>
    </div>
    
    <div>
      Keyup: 
      <div id="keyupField"></div>
    </div>
 
  </body>
</html>

Key and Char code table

For your reference here is collected values from test application. Format is like in example, event.keyCode / event.charCode.

keykeyPresskeyDownKeyup
048/4848/4848/48
149/4949/4949/49
250/5050/5050/50
351/5151/5151/51
452/5252/5252/52
553/5353/5353/53
654/5454/5454/54
755/5555/5555/55
856/5656/5656/56
957/5757/5757/57
*/+56/4242/4256/42
#51/3535/3551/35
C8/88/88/8
green0/6358663586/635860/63586
center0/6355763557/63557[n/a]/[n/a]
left37/6349563495/63495[n/a]/[n/a]
up38/6349763497/63497[n/a]/[n/a]
right39/6349663496/63496[n/a]/[n/a]
down40/6349863498/63498[n/a]/[n/a]
Related Discussions
Thread Thread Starter Forum Replies Last Post
CBA, menu and key events joker_pl Symbian User Interface 1 2005-09-19 10:27
Turning off Warning Tones dgaur General Symbian C++ 7 2007-09-06 06:06
A question about multiple views and key event handling EeroS Symbian User Interface 2 2007-07-13 09:35
Ped - in-phone programmers editor y.a.k Python 169 Yesterday 12:02
UI widgets in svg format? digitalmonkey Mobile Java Tools & SDKs 0 2007-02-14 00:46
 
Powered by MediaWiki