contact closure to send usb keypad function

I am using an Arduino uno for my project. I am trying to use a contact closure to trigger the uno to send the charter 9. I have figured that digital pin 2 is what needs to be connected to the contact to trigger a response on the uno. By this the TX light flashes, but nothing happens. I am brand new at programming, and have learned a whole lot lately, but I need a little guidance to figure this out. Thanks.

#include <Keypad.h>

const byte ROWS = 1; //four rows
const byte COLS = 1; //three columns
char keys[ROWS][COLS] =
byte rowPins[ROWS] = {2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()

void loop()
char key = keypad.getKey();

if (int(key) != 0){

Have you opened up the serial monitor to look at the output?

Is it set to the same baud rate?

Why are you using a matrix key pad code for just a simple contact closure? Just a digital read would do.