<commit_before>var KEY_LEFT = 37;
var KEY_RIGHT = 39;
var KEY_UP = 38;
var KEY_DOWN = 40;
var KEY_SPACE = 32;
var KEY_SHIFT = 16;
var KEY_BACK_SPACE = 8;
var KEY_E = 'E'.charCodeAt(0);

var KEY_MAPPINGS = {
    ['A'.charCodeAt(0)]: KEY_LEFT,
    ['D'.charCodeAt(0)]: KEY_RIGHT,
    ['W'.charCodeAt(0)]: KEY_UP,
    ['S'.charCodeAt(0)]: KEY_DOWN,
};

// This mapping assumes a canonical gamepad setup as seen in:
// https://w3c.github.io/gamepad/#remapping
// Which seems to work well with my xbox 360 controller.
// I based this code on examples from:
// https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API
var GAME_PAD_MAPPINGS = {
    [KEY_UP]: 0,// Could change this to KEY_JUMP
    [KEY_SPACE]: 2,
    //12: KEY_UP,// Right now up => jump, but on a game pad we don't want that. We should probably make up not jump and uncomment this.
    [KEY_DOWN]: 13,
    [KEY_LEFT]: 14,
    [KEY_RIGHT]: 15,
};

var physicalKeysDown = {};
var keysDown = {};

// Apparently, depending on the button type, either button.pressed or button == 1.0 indicates the button is pressed.
function buttonIsPressed(button) {
  if (typeof(button) == "object") return button.pressed;
  return button == 1.0;
}
function isKeyDown(keyCode) {
    if (keysDown[keyCode]) return true;
    // If a mapping exists for the current key code to a gamepad button,
    // check if that gamepad button is pressed.
    var buttonIndex = GAME_PAD_MAPPINGS[keyCode];
    if (typeof(buttonIndex) !== 'undefined') {
        // There can be multiple game pads connected. For now, let's just check all of them for the button.
        var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads : []);
        for (var gamepad of gamepads) {
            if (!gamepad) continue;
            if (buttonIsPressed(gamepad.buttons[buttonIndex])) return true;
        }
    }
}


$(document).on('keydown', event => {<commit_msg>Add a debug line I often use.<commit_after>var KEY_LEFT = 37;
var KEY_RIGHT = 39;
var KEY_UP = 38;
var KEY_DOWN = 40;
var KEY_SPACE = 32;
var KEY_SHIFT = 16;
var KEY_BACK_SPACE = 8;
var KEY_E = 'E'.charCodeAt(0);

var KEY_MAPPINGS = {
    ['A'.charCodeAt(0)]: KEY_LEFT,
    ['D'.charCodeAt(0)]: KEY_RIGHT,
    ['W'.charCodeAt(0)]: KEY_UP,
    ['S'.charCodeAt(0)]: KEY_DOWN,
};

// This mapping assumes a canonical gamepad setup as seen in:
// https://w3c.github.io/gamepad/#remapping
// Which seems to work well with my xbox 360 controller.
// I based this code on examples from:
// https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API
var GAME_PAD_MAPPINGS = {
    [KEY_UP]: 0,// Could change this to KEY_JUMP
    [KEY_SPACE]: 2,
    //12: KEY_UP,// Right now up => jump, but on a game pad we don't want that. We should probably make up not jump and uncomment this.
    [KEY_DOWN]: 13,
    [KEY_LEFT]: 14,
    [KEY_RIGHT]: 15,
};

var physicalKeysDown = {};
var keysDown = {};

// Apparently, depending on the button type, either button.pressed or button == 1.0 indicates the button is pressed.
function buttonIsPressed(button) {
  if (typeof(button) == "object") return button.pressed;
  return button == 1.0;
}
function isKeyDown(keyCode) {
    if (keysDown[keyCode]) return true;
    // If a mapping exists for the current key code to a gamepad button,
    // check if that gamepad button is pressed.
    var buttonIndex = GAME_PAD_MAPPINGS[keyCode];
    if (typeof(buttonIndex) !== 'undefined') {
        // There can be multiple game pads connected. For now, let's just check all of them for the button.
        var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads : []);
        for (var gamepad of gamepads) {
            if (!gamepad) continue;
            if (buttonIsPressed(gamepad.buttons[buttonIndex])) return true;
        }
    }
}


$(document).on('keydown', event => {
    //console.log(event.which);
{'fraction_non_alphanumeric': 0.1268170426065163, 'fraction_numerical': 0.01804511278195489, 'mean_word_length': 3.3905390539053903, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3917177', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1321, 'n_words': 417}