+ // Make sure there aren't any duplicate keys
+ uint8_t c;
+ for ( c = 0; c < KeyIndex_BufferUsed; c++ )
+ if ( KeyIndex_Buffer[c] == positionCounter )
+ break;
+
+ // No duplicate keys, add it to the buffer
+ if ( c == KeyIndex_BufferUsed )
+ bufferAdd( positionCounter );
+ }
+ }
+ // Remove the key from the buffer
+ else if ( positionCounter < 124 && positionCounter > 0x0B )
+ {
+ // Check for the released key, and shift the other keys lower on the buffer
+ uint8_t c;
+ for ( c = 0; c < KeyIndex_BufferUsed; c++ )
+ {
+ // Key to release found
+ if ( KeyIndex_Buffer[c] == positionCounter )
+ {
+ // Shift keys from c position
+ for ( uint8_t k = c; k < KeyIndex_BufferUsed - 1; k++ )
+ KeyIndex_Buffer[k] = KeyIndex_Buffer[k + 1];
+
+ // Decrement Buffer
+ KeyIndex_BufferUsed--;
+
+ break;
+ }