Skip to content

Can I know what key a player pressed? #292

Answered by saul
KilinW asked this question in Questions
Discussion options

You must be logged in to vote

Yes, this is possible, but only for perspective/POV demos. This information isn't recorded (directly) in GOTV demos. Find some example TypeScript below:

import * as assert from "assert";
import { DemoFile } from "demofile";
import * as fs from "fs";

function parseDemoFile(path: string) {
  fs.readFile(path, (err, buffer) => {
    assert.ifError(err);

    const demoFile = new DemoFile();

    demoFile.on("usercmd", usercmd => {
      // Only log every 1000th user command to reduce spam
      if (usercmd.tickCount % 1000 !== 0) return;

      console.log("usercmd", usercmd.buttons);
    });

    demoFile.on("end", e => {
      if (e.error) {
        console.error("Error during parsing:", e.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by KilinW
Comment options

You must be logged in to vote
1 reply
@saul
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants