Keyboard In computing, a keyboard is an input device, partially modeled after the typewriter...

6
Keyboard In computing , a keyboard is an input device , partially modeled after the typewriter keyboard , which uses an arrangement of buttons or keys , to act as mechanical levers or electronic switches. A keyboard typically has characters printed on the keys and each press of a key typically corresponds to a single written symbol. However, to produce some symbols requires pressing and holding several keys simultaneously or in sequence. While most keyboard keys produce letters, numbers or

Transcript of Keyboard In computing, a keyboard is an input device, partially modeled after the typewriter...

Page 1: Keyboard In computing, a keyboard is an input device, partially modeled after the typewriter keyboard, which uses an arrangement of buttons or keys, to.

KeyboardIn computing, a keyboard is an input device, partially modeled after the typewriter keyboard, which uses an arrangement of buttons or keys, to act as mechanical levers or electronic switches. A keyboard typically has characters printed on the keys and each press of a key typically corresponds to a single written symbol. However, to produce some symbols requires pressing and holding several keys simultaneously or in sequence. While most keyboard keys produce letters, numbers or signs (characters), other keys or simultaneous key presses can produce actions or computer commands.

Page 2: Keyboard In computing, a keyboard is an input device, partially modeled after the typewriter keyboard, which uses an arrangement of buttons or keys, to.

Keyboard Message Processing

Window has designed to support different types of keyboards for different languages, with different locations on the keyboard for normal and accented characters.

When you de-press a key, windows sends a WM-KEYDOWN message to the window with the input focus.

Window with input focus is the window with highligtted caption bar.

When the key is released, windows sends a WM-KEYUP message.

We can determine which key was pressed by examining the wParam parameter that is sent with the keyboard messages.

wParam will endode the “virtual key code”for the key pressed and released.

Page 3: Keyboard In computing, a keyboard is an input device, partially modeled after the typewriter keyboard, which uses an arrangement of buttons or keys, to.

Virtual key codes are one of the ways windows makes sure that a program written for one type of computer keyboard will function properly on another type.

The idea is that no matter what type of hardware is being used, the virtual key code for the A will have the same value.

The virtual key codes are defined in Windows.H. The virtual key codes for the VK_F1 is F1

function key, and VK_TAB for the Tab key, VK_CONTROL for the cntl key and so on.

Page 4: Keyboard In computing, a keyboard is an input device, partially modeled after the typewriter keyboard, which uses an arrangement of buttons or keys, to.

The only key which does not have the virtual key code is Alt.

The status of the Alt key is passed with the lParam value in a WM_KEYDOWN or WM_KEYUP message.

Page 5: Keyboard In computing, a keyboard is an input device, partially modeled after the typewriter keyboard, which uses an arrangement of buttons or keys, to.

Processing WM_KEYDOWN Messagelong FAR PASCAL WndProc( HWND hWnd, WORD

wMessage,WORD wParam, LONG lParam)

{ static BOOL bShiftDown= FALSE;

switch(wMessage) //process window message

{

case WM_KEYDOWN :

switch(wParam)

{

case ‘A’:

/* code */

break;

Page 6: Keyboard In computing, a keyboard is an input device, partially modeled after the typewriter keyboard, which uses an arrangement of buttons or keys, to.

case VK_TAB: /*tab key*/ /*code */Break; case VK_SHIFT: bShiftDown=TRUE; // shift key pressed break;} break;}case WM_KEYUP: switch(wParam) { case VK_SHIFT: bShiftDOwn=FALSE; // shift key released break;