Skip to main content
100%

Test of JS Keyboard Events

✓ Published0🌍 Public
Pplueckeb@rptu.de
Last edited Feb 19, 2024
Created on Feb 19, 2024

This example demonstrates how JavaScript keyboard events can drive interactive visualizations in the VizHub V3 runtime environment. It listens for key presses and uses the container element’s client dimensions to render responsive updates, leveraging the V3’s hot-reloading and state management API. The code employs the `main` function pattern with `state` and `setState` to handle immutable state transitions, providing a template for integrating user input into data-driven graphics. No external libraries are used, relying instead on native DOM event handling and the environment’s built-in rendering loop.

AI-generated description

A blank slate starting point showing the "Hello World" for the VizHub V3 Runtime Environment, which supports continuous hot reloading with interactive widgets.

  • There is no index.html - that's what triggers the V3 Runtime
  • The entry point is the main function exported from index.js
  • The main function takes an argument container, a DIV that has measurable dimensions using clientWidth and clientHeight
  • The second argument to main is an options object containing state and setState.
  • The state of the application is stored in state, which is initialized as an empty object {}.
  • The setState function can be called with a function that uses the previous state to create a new state object using immutable update patterns.
  • For an interactive example, see Mouse Follower.

Full course playlist: YouTube: Constructing Visualization 2024.

MIT Licensed

Similar vizzes