text: class KeyboardController {
      constructor(host, keys) {
          this.state = {};
          this.events = {};
          this.onKeyDown = (e) => {
              this.onKey(e, 1);
          };
          this.onKeyUp = (e) => {
              this.onKey(e, -1);
          };
          this.host = host;
          this.events = {};
          this.state = {};
          for (const key of keys) {
              this.state[key] = 0;
          }
      }
      hostConnected() {
          this.reset();
          this.host.addEventListener('keydown', this.onKeyDown);
          this.host.addEventListener('keyup', this.onKeyUp);
      }
      hostDisconnected() {
          this.host.removeEventListener('keydown', this.onKeyDown);
          this.host.removeEventListener('keyup', this.onKeyUp);
      }
      onKey(e, increment) {
          const { key } = e;
          if (this.state[key] === undefined) {
              return;
          }
          this.state[key] = Math.max(0, this.state[key] + increment);
          this.events[key] = e;
          this.host.requestUpdate();
      }
      getDetails() {
          return {
              state: this.state,
              events: this.events,
          };
      }
      reset() {
          this.state = Object.assign({}, this.state);
          for (const key in this.state) {
              this.state[key] = 0;
          }
      }
  }
  export { KeyboardController };
  