Heilan X3D Browser

KeyTrigger

Type

ChildNode.

Description

This node is used to (for example) start/stop TimeSensors according to keyboard inputs. The idea is you connect this node between a KeySensor and TimeSensor's enabled attribute, and the TimeSensor will then only trigger events when you hold down the specified key(s). You could also use a BooleanToggle node to get a toggling action.

Attributes

set_activeVal SFBool (input) The boolean value of the following set_key event. This is generated by KeySensor's isActive event, and tells you if the following set_key event is a key up or a key down event.

set_key SFString (input) To be connected to KeySensor's keyPress and keyRelease outputs. This will generate a _changed event, determined by the key that was passed in. Keys are represented as a single character string. So, calling set_key with a value of "a" would generate an a_changed event, with a boolean value determined by the last value sent to set_activeVal.

a_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "a".

b_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "b".

c_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "c".

d_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "d".

e_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "e".

f_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "f".

g_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "g".

h_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "h".

i_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "i".

j_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "j".

k_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "k".

l_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "l".

m_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "m".

n_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "n".

o_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "o".

p_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "p".

q_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "q".

r_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "r".

s_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "s".

t_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "t".

u_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "u".

v_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "v".

w_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "w".

x_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "x".

y_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "y".

z_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "z".

0_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "0".

1_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "1".

2_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "2".

3_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "3".

4_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "4".

5_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "5".

6_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "6".

7_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "7".

8_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "8".

9_changed SFBool (output) Generated when KeyTrigger receives a set_key event with a value of "9".

Example Use


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE X3D>
<X3D profile="Full">
	<Scene>
		<NavigationInfo type="ANY"/>

		<Transform DEF="boxPos" translation="0 0 0">
			<Shape>
				<Appearance>
					<Material DEF="boxColour" diffuseColor="1.0 0.0 0.0 "/>
				</Appearance>
				<Box/>
			</Shape>
		</Transform>

		<KeySensor DEF="keybo"/>
		<KeyTrigger DEF="keyma"/>
		<TimeSensor DEF="testSensor" enabled="FALSE" cycleInterval="5.0" loop="TRUE"/>
		<PositionInterpolator DEF="PositionInterp" key="0.0 0.5 1.0" keyValue="1 0 0 0 1 0 0 0 1"/>

		<ROUTE fromNode="keybo" fromField="isActive" toNode="keyma" toField="set_activeVal"/>
		<ROUTE fromNode="keybo" fromField="keyPress" toNode="keyma" toField="set_key"/>
		<ROUTE fromNode="keybo" fromField="keyRelease" toNode="keyma" toField="set_key"/>
		<ROUTE fromNode="keyma" fromField="s_changed" toNode="testSensor" toField="enabled"/>

		<ROUTE fromNode="testSensor" fromField="fraction_changed" toNode="PositionInterp" toField="set_fraction"/>
		<ROUTE fromNode="PositionInterp" fromField="value_changed" toNode="boxPos" toField="translation"/>
	</Scene>
</X3D>