media @ VU
web3d-keyboard.vr
web3d-keyboard.vr
(wrl
)
[ flux /
bitmanagement /
cortona /
octaga
]
keys
Web3D/VR
extern
#@extern @vr-extern-monitor.wrl
proto
PROTO keyboard [
eventOut MFString string
]{
body
DEF KEYBOARD_INTERFACE Script {
field SFNode me USE KEYBOARD_INTERFACE
field SFInt32 oldMask 0
eventIn SFNode onEvent
eventOut MFString string IS string
functions
url "vrmlscript:
function initialize()
{
// tell what events
oldMask = Browser.eventMask;
//Browser.eventMask = 1<<5; // KeyDown Only...
Browser.eventMask = ((1<<5) | (1<<6)); // KeyDown and KeyUp
// add event observer
Browser.addRoute(Browser,'event_changed',me,'onEvent');
}
function shutdown()
{
// remove event observer
Browser.eventMask = oldMask;
Browser.deleteRoute(Browser,'event_changed',me,'onEvent');
}
events
function onEvent(e,t) {
if(e.type == 'keydown') {
str = 'press: ' + e.keyCode;
//print(str);
string = new MFString(str);
e.returnValue = false; // no further processing
} else if(e.type == 'keyup') {
str = 'release: ' + e.keyCode;
//print(str);
string = new MFString(str);
e.returnValue = false; // no further processing
}
}
"
}
}
Viewpoint { position 0 0 10 }
DEF keyboard keyboard { }
DEF monitor monitor { string [ "hit a key" "(click to focus)" ] }
ROUTE keyboard.string TO monitor.string
(C) A. Eliëns
21/5/2007
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.