PS2 Keyboard - Works for a while - then sends random codes

Just wondering if anyone has experienced an issue with using a PS2 keyboard where the codes are being sent properly for a while, and then suddenly strange codes start being sent?

I start my arduino and I press keys on my keypad, seeing the numbers corresponding to the key I press. This works for about 15 minutes, and then the key presses start to show up with somewhat random numbers, and even an extra “press” when the key is going up as opposed to going down… Any ideas?

In case anyone encounters this problem and finds this thread, I have devised a workaround. It seems that the bit buffer gets out of sync occasionally. So I added some code to the PS2Keyboard.cpp file to reset the bit buffer if no input has been received for a brief period of time.

unsigned long time;

// The ISR for the external interrupt
ISR(INT1_vect) {
  int value = digitalRead(ps2Keyboard_DataPin);
  
  unsigned long timeDiff = millis() - time;
  if(timeDiff > 100)
  {
	ps2Keyboard_CurrentBuffer = 0;
	ps2Keyboard_BufferPos = 0;
  }
  
  time = millis();

  if(ps2Keyboard_BufferPos > 0 && ps2Keyboard_BufferPos < 9) {
    ps2Keyboard_CurrentBuffer |= (value << (ps2Keyboard_BufferPos - 1));
  }
  
  ps2Keyboard_BufferPos++;
  
  if(ps2Keyboard_BufferPos == 11) {
    if(ps2Keyboard_CurrentBuffer == PS2_KC_BREAK) {
      ps2Keyboard_BreakActive = true;
    } else if(ps2Keyboard_BreakActive) {
      ps2Keyboard_BreakActive = false;
    } else {
      ps2Keyboard_CharBuffer = ps2Keyboard_CurrentBuffer;
      
    }
    ps2Keyboard_CurrentBuffer = 0;
    ps2Keyboard_BufferPos = 0;
  }
}