Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Keyboard In computing, a keyboard is an input device, partially modeled after the typewriter keyboard, which uses an arrangement of buttons or keys, to."— Presentation transcript:

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 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.computinginput devicetypewriter keyboardkeysprintedsymbol lettersnumberssignscharacters

2 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.

3  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.

4  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.

5 Processing WM_KEYDOWN Message long 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;

6 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;


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

Similar presentations


Ads by Google