ParallelGraphics
Home  »  Developer Zone  »  Products  »  Cortona VRML Client for Mac OS X  »  VRML Extensions  »  Keyboard Input
Up to VRML Extensions

AdvancedAppearance 

Splines 

Nurbs 

Keyboard Input 

SFVec2f Interpolator 

Drag & Drop Handling 


Subscribe to Newsletter
 


Google Searchsite search:

 

%(domain)s %(domain)s
Install Cortona VRML Client!

Outline 3D

Try RobinZone!


Keyboard Input
KbdSensor
Scene size: 567bytes

The KbdSensor node generates events based on input from a keyboard.

Click anywhere in the 3D window and press any alphanumeric keys.


Node description
KbdSensor {
 exposedField	SFBool	enabled TRUE
 exposedField	SFBool	isActive FALSE
 eventOut		SFInt32	keyDown
 eventOut		SFInt32	keyUp
}
 
enabled indicates whether the sensor is currently paying attention to a keyboard input. If enabled receives TRUE and isActive is TRUE, the sensor reacts on input from a keyboard. In this case, the user cannot navigate in the 3D window using keyboard commands.

 
isActive allows to control the sensor. If isActive receives a TRUE event, the sensor processes all keyboard input. Otherwise, the input is treated with a browser.

 
keyDown and keyUp events generate 32-bit value containing the character code of the key that was pressed or released. The primary two bytes specify the virtual-key code of the nonsystem key, and the secondary - key-state flags.



Example
#VRML V2.0 utf8
NavigationInfo {
 type "EXAMINE"
}
Background {
 skyColor [1 1 1]
}
DEF KS KbdSensor {
 isActive TRUE
}
Shape {
 geometry DEF TXT Text {
  string ["?"]
  fontStyle FontStyle	{
  justify ["MIDDLE", "MIDDLE"]
  family "TYPEWRITER"
  style "BOLD"
  size 4
  }
 }
 appearance Appearance {
  material Material {
   diffuseColor 0.02 0.38 0.61
  }
 } 
}
DEF SCR Script	{
 directOutput TRUE
 eventIn SFInt32 go
 field SFNode TXT USE TXT
 field MFString string [""]
 url ["javascript:
  function go(val,ts){
   string[0]=
    String.fromCharCode(val.toString());
   TXT.string=string;
  }
  "]
}
ROUTE KS.keyDown TO SCR.go

You can see this example in Cortona at top left corner of this page.




Last updated: Tue, 19 Aug 2008
© 2000-2008 ParallelGraphics. All rights reserved. Terms of use.