I recommend you check out this website called HowStuffWorks on How Computer Keyboards Work. It states in sum:
As you type, the processor in the keyboard analyzes the key matrix and
determines what characters to send to the computer. It maintains these
characters in its memory buffer and then sends the data.
and
Many keyboards connect to the computer through a cable with a PS/2 or
USB (Universal Serial Bus) connector. Laptops use internal connectors.
and finally
Whether it's through a cable or wireless, the signal from the keyboard
is monitored by the computer's keyboard controller. This is an
integrated circuit (IC) that processes all of the data that comes from
the keyboard and forwards it to the operating system. When the
operating system (OS) is notified that there is data from the
keyboard, it checks to see if the keyboard data is a system level
command. A good example of this is Ctrl-Alt-Delete on a Windows
computer, which reboots the system. Then, the OS passes the keyboard
data on to the current application.
The data is sent via cable or wireless also (IR or other wireless technology).
Wikipedia also has a nice writeup on keyboards,
Computer keyboards include control circuitry to convert key presses
into key codes that the computer's electronics can understand. The key
switches are connected via the printed circuit board in an electrical
X-Y matrix where a voltage is provided sequentially to the Y lines
and, when a key is depressed, detected sequentially by scanning the X
lines.