Code

// 8 -> PIN 1 (top of cable, when keyboard is facing up and spacebar is nearest you)
// 22 -> PIN 2
// 24 -> PIN 3
// 26 -> PIN 4
// 28 -> PIN 5
// 30 -> PIN 6
// 32 -> PIN 7
// 34 -> PIN 8
// 36 -> PIN 9
// 38 -> PIN 10
// 40 -> PIN 11
// 42 -> PIN 12
// 44 -> PIN 13
// 46 -> PIN 14
// 48 -> PIN 15
// 50 -> PIN 16
// 52 -> PIN 17

int r_pins[] = {8, 22, 24, 26, 28, 30, 32, 50};
int w_pins[] = {38, 40, 42, 44, 46, 48, 52};

// 10   11   12   13   14   15   17
char* kdata[][8] = {
  {"k", "l", ";", "'", "m", ",", "."},            // 1
  {"u", "i", "o", "P", "!", "!", "j"},            // 2 - 1/2, ENTER
  {"7", "8", "9", "0", "-", "=", "!"},            // 3 - BS
  {"!", "1", "2", "3", "4", "5", "6"},            // 4 - TABS
  {"!", "q", "w", "e", "r", "t", "y"},            // 5 - TAB
  {"!", "a", "s", "d", "f", "g", "h"},            // 6 - CAPSLOCK
  {"!", "z", "x", "c", "v", "b", "n"},            // 7 - LSHIFT
  {"!", "/", "!", "!", " ", "!", "!"},            // 16 - RSHIFT, CODE, MARGIN, SPACEBAR, WORDERASER, CORRECT
};

void setup() {
  int i;
  Serial.begin(9600);
  delay(1500);

  Serial.println("Setting up pins");
  for (i = 0; i <=7; i++) {
    pinMode(r_pins[i], INPUT_PULLUP);
  }
  for (i = 0; i <=6; i++) {
    pinMode(w_pins[i], OUTPUT);
    digitalWrite(w_pins[i], HIGH);
  }

  Serial.println("Ready...");
}


void loop() {
  int r;  int w;  int val;

  // Scan rows individually by bringing the column low and checking the rows for grounded pins
  for (w = 0;  w <= 6; w++) {
    digitalWrite(w_pins[w], LOW);

      for (r = 0; r <= 7; r++) {
        val = digitalRead(r_pins[r]);

        if (val == 0) {
          // This signal is grounded, so we have a keypress
          char key = *kdata[r][w];
          Serial.print(key);
          delay(120);    // Wait to force a settle/debounce
        }

      }

    digitalWrite(w_pins[w], HIGH);
    }
  }