INNER CODE UNIT · TypeScript

onKeyPress

jamesroutley/24a2 · src/engine.ts:416

    function onKeyPress(this: CanvasIOManager, event: KeyboardEvent) {
      if (!this._keyPressed) {
        return;
      }

      // TODO: We currently ignore repeat keydown events. These are fired when
      // a key is held down. We do this because there's a pause between the
      // first (repeat: false) event and subsequent (repeat: true) events. This
      // causes jittery behaviour.
      // We should probably do something like call this._keyPressed at a
      // constant rate.
      // In the meantime, we just ignore repeated events. This is also how the
      // P5 implementation worked.
      if (event.repeat) {
        return;
      }

      switch (event.key) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…