<commit_before>
function Keyboard() {
    this.keys = {KEY_A: 0, KEY_B: 1, KEY_SELECT: 2, KEY_START: 3, KEY_UP: 4, KEY_DOWN: 5, KEY_LEFT: 6, KEY_RIGHT: 7};
    
    this.state1 = Array(8);
    for (var i = 0; i < this.state1.length; i++) this.state1[i] = 0x40;
    this.state2 = Array(8);
    for (var i = 0; i < this.state2.length; i++) this.state2[i] = 0x40;
}

Keyboard.prototype.setKey = function(key, value) {
    switch (key) {
	    case 88: this.state1[this.keys.KEY_A] = value; break;      // X
	    case 90: this.state1[this.keys.KEY_B] = value; break;      // Z
	    case 17: this.state1[this.keys.KEY_SELECT] = value; break; // Right Ctrl
	    case 13: this.state1[this.keys.KEY_START] = value; break;  // Enter
	    case 38: this.state1[this.keys.KEY_UP] = value; break;     // Up
	    case 40: this.state1[this.keys.KEY_DOWN] = value; break;   // Down
	    case 37: this.state1[this.keys.KEY_LEFT] = value; break;   // Left
	    case 39: this.state1[this.keys.KEY_RIGHT] = value; break;  // Right

	    case 103: this.state2[this.keys.KEY_A] = value; break;     // Num-7
	    case 105: this.state2[this.keys.KEY_B] = value; break;     // Num-9
	    case 99: this.state2[this.keys.KEY_SELECT] = value; break; // Num-3
	    case 97: this.state2[this.keys.KEY_START] = value; break;  // Num-1
	    case 104: this.state2[this.keys.KEY_UP] = value; break;    // Num-8
	    case 98: this.state2[this.keys.KEY_DOWN] = value; break;   // Num-2
	    case 100: this.state2[this.keys.KEY_LEFT] = value; break;  // Num-4
	    case 102: this.state2[this.keys.KEY_RIGHT] = value; break; // Num-6
	}
}

Keyboard.prototype.keyDown = function(evt) {
	this.setKey(evt.keyCode, 0x41);
	if (evt.preventDefault) evt.preventDefault();
}
Keyboard.prototype.keyUp = function(evt) {
	this.setKey(evt.keyCode, 0x40);
	if (evt.preventDefault) evt.preventDefault();
}

var keyboard = new Keyboard();
document.onkeydown = function(evt) {keyboard.keyDown(evt)}
document.onkeyup = function(evt) {keyboard.keyUp(evt)}
<commit_msg>Only keyboard keys used by the emulator are now disabled<commit_after>
function Keyboard() {
    this.keys = {KEY_A: 0, KEY_B: 1, KEY_SELECT: 2, KEY_START: 3, KEY_UP: 4, KEY_DOWN: 5, KEY_LEFT: 6, KEY_RIGHT: 7};
    
    this.state1 = Array(8);
    for (var i = 0; i < this.state1.length; i++) this.state1[i] = 0x40;
    this.state2 = Array(8);
    for (var i = 0; i < this.state2.length; i++) this.state2[i] = 0x40;
}

Keyboard.prototype.setKey = function(key, value) {
    switch (key) {
	    case 88: this.state1[this.keys.KEY_A] = value; break;      // X
	    case 90: this.state1[this.keys.KEY_B] = value; break;      // Z
	    case 17: this.state1[this.keys.KEY_SELECT] = value; break; // Right Ctrl
	    case 13: this.state1[this.keys.KEY_START] = value; break;  // Enter
	    case 38: this.state1[this.keys.KEY_UP] = value; break;     // Up
	    case 40: this.state1[this.keys.KEY_DOWN] = value; break;   // Down
	    case 37: this.state1[this.keys.KEY_LEFT] = value; break;   // Left
	    case 39: this.state1[this.keys.KEY_RIGHT] = value; break;  // Right

	    case 103: this.state2[this.keys.KEY_A] = value; break;     // Num-7
	    case 105: this.state2[this.keys.KEY_B] = value; break;     // Num-9
	    case 99: this.state2[this.keys.KEY_SELECT] = value; break; // Num-3
	    case 97: this.state2[this.keys.KEY_START] = value; break;  // Num-1
	    case 104: this.state2[this.keys.KEY_UP] = value; break;    // Num-8
	    case 98: this.state2[this.keys.KEY_DOWN] = value; break;   // Num-2
	    case 100: this.state2[this.keys.KEY_LEFT] = value; break;  // Num-4
	    case 102: this.state2[this.keys.KEY_RIGHT] = value; break; // Num-6
	    default: return true;
	}
	return false; // preventDefault
}

Keyboard.prototype.keyDown = function(evt) {
	if (!this.setKey(evt.keyCode, 0x41) && evt.preventDefault)
	    evt.preventDefault();
}
Keyboard.prototype.keyUp = function(evt) {
	if (!this.setKey(evt.keyCode, 0x40) && evt.preventDefault)
	    evt.preventDefault();
}

var keyboard = new Keyboard();
document.onkeydown = function(evt) {keyboard.keyDown(evt)}
document.onkeyup = function(evt) {keyboard.keyUp(evt)}

{'fraction_non_alphanumeric': 0.15921720222275912, 'fraction_numerical': 0.043971973906740756, 'mean_word_length': 3.0548481880509306, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '854440', 'n_tokens_mistral': 1685, 'n_tokens_neox': 1573, 'n_words': 351}