public void interrupt() {
    int a = dcpu.registers[0];
    if (a == 0) {
      for (int i = 0; i < keyBuffer.length; i++) {
        keyBuffer[i] = 0;
      }
      krp = 0;
      kwp = 0;
    } else if (a == 1) {
      if ((dcpu.registers[2] = keyBuffer[(krp & 0x3F)]) != 0)
        keyBuffer[(krp++ & 0x3F)] = 0;
    }
    else if (a == 2) {
      int key = dcpu.registers[1];
      if ((key >= 0) && (key < 256))
        dcpu.registers[2] = (char)(isDown[key] ? 1 : 0);
      else
        dcpu.registers[2] = 0;
    }
    else if (a == 3) {
      interruptMessage = dcpu.registers[1];
    }
  }