<commit_before>let initialized = false;

export const lastKeyboardEvents: WegasKeyboardEvent = {
  keyCode: undefined,
  ctrlKey: undefined,
  altKey: undefined,
};

function keyboardEventHandler(e: KeyboardEvent) {
  lastKeyboardEvents.keyCode = e.keyCode;
  lastKeyboardEvents.ctrlKey = e.ctrlKey;
  lastKeyboardEvents.altKey = e.altKey;
}

if (!initialized) {
  initialized = true;
  window.addEventListener('keydown', keyboardEventHandler);
  window.addEventListener('keyup', keyboardEventHandler);
}
<commit_msg>keyboard event catcher cleaned<commit_after>let initialized = false;

export const lastKeyboardEvents: WegasKeyboardEvent = {
  keyCode: undefined,
  ctrlKey: undefined,
  altKey: undefined,
};

function keyboardEventHandler(e: KeyboardEvent) {
  lastKeyboardEvents.keyCode = e.keyCode;
  lastKeyboardEvents.ctrlKey = e.ctrlKey;
  lastKeyboardEvents.altKey = e.altKey;
}

function keyboardEventCleanerHandler() {
  lastKeyboardEvents.keyCode = undefined;
  lastKeyboardEvents.ctrlKey = undefined;
  lastKeyboardEvents.altKey = undefined;
}

if (!initialized) {
  initialized = true;
  window.addEventListener('keydown', keyboardEventHandler);
  window.addEventListener('keyup', keyboardEventCleanerHandler);
}

{'fraction_non_alphanumeric': 0.09861450692746536, 'fraction_numerical': 0.0, 'mean_word_length': 6.266272189349112, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3136378', 'n_tokens_mistral': 350, 'n_tokens_neox': 369, 'n_words': 71}