{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.0",
    "@xsd:noNamespaceSchemaLocation":"https://www.web3d.org/specifications/x3d-3.0.xsd",
    "JSON schema":"https://www.web3d.org/specifications/x3d-4.0-JSONSchema.autogenerated.json",
    "head": {
        "meta": [
          {
            "@name":"title",
            "@content":"KeySensorActivationKeySwitchTest.x3d"
          },
          {
            "@name":"description",
            "@content":"A simple scene to show KeySensor functionality using Text nodes."
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"22 June 2001"
          },
          {
            "@name":"modified",
            "@content":"20 October 2019"
          },
          {
            "@name":"warning",
            "@content":"This doesn't work because there is no KeySensor implementation yet! Prototype script (written in Java) or native node support for KeySensor is needed."
          },
          {
            "@name":"warning",
            "@content":"enabled accessType needs to be changed to exposedField once supported by Script capabilities"
          },
          {
            "@name":"reference",
            "@content":"https://www.web3d.org/x3d/specification-2000july/part1/nodesDef.html#KeySensor"
          },
          {
            "@name":"reference",
            "@content":"https://www.web3d.org/x3d/sai/javadoc/org/web3d/x3d/sai/Core/KeySensor.html"
          },
          {
            "@name":"identifier",
            "@content":"https://www.web3d.org/x3d/content/examples/Basic/development/KeySensorActivationKeySwitchTest.x3d"
          },
          {
            "@name":"reference",
            "@content":"https://www.web3d.org/x3d/content/examples/Basic/ConformanceNist/Sensors/Keyboard/KeySensorActivationKeySwitchTest.x3d"
          },
          {
            "@name":"subject",
            "@content":"KeySensor"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"20 April 2026"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, https://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"reference",
            "@content":"X3D JSON encoding: https://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-children":[
          {
            "#comment":"The KeySensor prototype can be omitted if native-node Keysensor support is provided by the VRML browser."
          },
          { "WorldInfo":
            {
              "@title":"KeySensorActivationKeySwitchTest.x3d"
            }
          },
          { "ProtoDeclare":
            {
              "@name":"KeySensor",
              "ProtoInterface": {
                  "-children":[
                    {
                      "#comment":"warning: enabled needs to become an exposedField once Scripts support exposedField"
                    }
                  ],
                  "field": [
                    {
                      "@name":"enabled",
                      "@accessType":"initializeOnly",
                      "@type":"SFBool",
                      "@value":true
                    },
                    {
                      "@name":"set_enabled",
                      "@accessType":"inputOnly",
                      "@type":"SFBool"
                    },
                    {
                      "@name":"enabled_changed",
                      "@accessType":"outputOnly",
                      "@type":"SFBool"
                    },
                    {
                      "@name":"isActive",
                      "@accessType":"outputOnly",
                      "@type":"SFBool"
                    },
                    {
                      "@name":"keyPress",
                      "@accessType":"outputOnly",
                      "@type":"SFInt32"
                    },
                    {
                      "@name":"keyRelease",
                      "@accessType":"outputOnly",
                      "@type":"SFInt32"
                    },
                    {
                      "@name":"actionKeyPress",
                      "@accessType":"outputOnly",
                      "@type":"SFInt32"
                    },
                    {
                      "@name":"actionKeyRelease",
                      "@accessType":"outputOnly",
                      "@type":"SFInt32"
                    },
                    {
                      "@name":"altKey",
                      "@accessType":"outputOnly",
                      "@type":"SFBool"
                    },
                    {
                      "@name":"controlKey",
                      "@accessType":"outputOnly",
                      "@type":"SFBool"
                    },
                    {
                      "@name":"shiftKey",
                      "@accessType":"outputOnly",
                      "@type":"SFBool"
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    {
                      "#comment":"First node in prototype indicates node type, use Group so that this sensor is ChildNodeType."
                    },
                    { "Group":
                      {
                        "-children":[
                          { "Script":
                            {
                              "@DEF":"KeySensorScript",
                              "field": [
                                {
                                  "@name":"altKey",
                                  "@accessType":"outputOnly",
                                  "@type":"SFBool"
                                },
                                {
                                  "@name":"keyPress",
                                  "@accessType":"outputOnly",
                                  "@type":"SFInt32"
                                },
                                {
                                  "@name":"set_enabled",
                                  "@accessType":"inputOnly",
                                  "@type":"SFBool"
                                },
                                {
                                  "@name":"keyRelease",
                                  "@accessType":"outputOnly",
                                  "@type":"SFInt32"
                                },
                                {
                                  "@name":"enabled",
                                  "@accessType":"initializeOnly",
                                  "@type":"SFBool"
                                },
                                {
                                  "@name":"shiftKey",
                                  "@accessType":"outputOnly",
                                  "@type":"SFBool"
                                },
                                {
                                  "@name":"actionKeyRelease",
                                  "@accessType":"outputOnly",
                                  "@type":"SFInt32"
                                },
                                {
                                  "@name":"isActive",
                                  "@accessType":"outputOnly",
                                  "@type":"SFBool"
                                },
                                {
                                  "@name":"actionKeyPress",
                                  "@accessType":"outputOnly",
                                  "@type":"SFInt32"
                                },
                                {
                                  "@name":"enabled_changed",
                                  "@accessType":"outputOnly",
                                  "@type":"SFBool"
                                },
                                {
                                  "@name":"controlKey",
                                  "@accessType":"outputOnly",
                                  "@type":"SFBool"
                                }
                              ],
                              "IS": {
                                  "connect": [
                                    {
                                      "@nodeField":"enabled",
                                      "@protoField":"enabled"
                                    },
                                    {
                                      "@nodeField":"set_enabled",
                                      "@protoField":"set_enabled"
                                    },
                                    {
                                      "@nodeField":"enabled_changed",
                                      "@protoField":"enabled_changed"
                                    },
                                    {
                                      "@nodeField":"isActive",
                                      "@protoField":"isActive"
                                    },
                                    {
                                      "@nodeField":"keyPress",
                                      "@protoField":"keyPress"
                                    },
                                    {
                                      "@nodeField":"keyRelease",
                                      "@protoField":"keyRelease"
                                    },
                                    {
                                      "@nodeField":"actionKeyPress",
                                      "@protoField":"actionKeyPress"
                                    },
                                    {
                                      "@nodeField":"actionKeyRelease",
                                      "@protoField":"actionKeyRelease"
                                    },
                                    {
                                      "@nodeField":"altKey",
                                      "@protoField":"altKey"
                                    },
                                    {
                                      "@nodeField":"controlKey",
                                      "@protoField":"controlKey"
                                    },
                                    {
                                      "@nodeField":"shiftKey",
                                      "@protoField":"shiftKey"
                                    }
                                  ]
                              },
                              "#sourceCode":[
"",
"",
"ecmascript:",
"",
"// Native support for KeySensor node",
"// or keyboard-access code needed!",
"",
""
]
                            }
                          }
                        ]
                      }
                    }
                  ]
              }
            }
          },
          {
            "#comment":"============================================"
          },
          {
            "#comment":"Enabling this KeySensor (from TouchSensor.isActive) disables all other KeySensors."
          },
          { "KeySensor":
            {
              "@DEF":"SingleKeySensor",
              "@enabled":false
            }
          },
          { "Billboard":
            {
              "-children":[
                { "Transform":
                  {
                    "@translation":[0,2,0],
                    "-children":[
                      { "Shape":
                        {
                          "-geometry":
                            { "Text":
                              {
                                "@string":["Touch this text to enable","KeySensor activation keys then","press activation keys to test"],
                                "-fontStyle":
                                  { "FontStyle":
                                    {
                                      "@DEF":"MiddleMiddle",
                                      "@justify":["MIDDLE","MIDDLE"]
                                    }
                                  }
                              }
                            },
                          "-appearance":
                            { "Appearance":
                              {
                                "-material":
                                  { "Material":
                                    {
                                      "@diffuseColor":[0.9,0.9,0.4]
                                    }
                                  }
                              }
                            }
                        }
                      },
                      { "TouchSensor":
                        {
                          "@DEF":"StartMessageTouched",
                          "@description":"Touch this text to enable KeySensor activation keys then press activation keys to test"
                        }
                      },
                      { "ROUTE":
                        {
                          "@fromField":"isOver",
                          "@fromNode":"StartMessageTouched",
                          "@toField":"enabled",
                          "@toNode":"SingleKeySensor"
                        }
                      }
                    ]
                  }
                },
                { "Transform":
                  {
                    "@translation":[0,-1,0],
                    "-children":[
                      { "Switch":
                        {
                          "@DEF":"ActivationKeyMessageSwitch",
                          "@whichChoice":0,
                          "-children":[
                            {
                              "#comment":"ROUTE is not treated as a selectable child of Switch"
                            },
                            { "ROUTE":
                              {
                                "@fromField":"actionKeyPress",
                                "@fromNode":"SingleKeySensor",
                                "@toField":"whichChoice",
                                "@toNode":"ActivationKeyMessageSwitch"
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Zero",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["No activation keypress sensed...."],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@DEF":"SelectionAppearance",
                                      "-material":
                                        { "Material":
                                          {
                                            "@diffuseColor":[0,1,0]
                                          }
                                        }
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"One",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["F1"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Two",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["F2"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Three",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["F3"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Four",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["F4"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Five",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["F5"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Six",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["F6"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Seven",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["F7"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Eight",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["F8"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Nine",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["F9"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Ten",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["F10"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Eleven",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["F11"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Twelve",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["F12"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Thirteen",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["13: HOME"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Fourteen",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["14: END"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Fifteen",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["15: LEFT"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Sixteen",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["16: RIGHT"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Seventeen",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["17: UP"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Eighteen",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["18: DOWN"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Nineteen",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["19: PGUP"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            },
                            { "Shape":
                              {
                                "@DEF":"Twenty",
                                "-geometry":
                                  { "Text":
                                    {
                                      "@string":["20: PGDN"],
                                      "-fontStyle":
                                        { "FontStyle":
                                          {
                                            "@USE":"MiddleMiddle"
                                          }
                                        }
                                    }
                                  },
                                "-appearance":
                                  { "Appearance":
                                    {
                                      "@USE":"SelectionAppearance"
                                    }
                                  }
                              }
                            }
                          ]
                        }
                      }
                    ]
                  }
                }
              ]
            }
          }
        ]
    }
  }
}