Меню

Any лун on keyboard

Keyboard Input (Get Started with Win32 and C++)

The keyboard is used for several distinct types of input, including:

  • Character input. Text that the user types into a document or edit box.
  • Keyboard shortcuts. Key strokes that invoke application functions; for example, CTRL + O to open a file.
  • System commands. Key strokes that invoke system functions; for example, ALT + TAB to switch windows.

When thinking about keyboard input, it is important to remember that a key stroke is not the same as a character. For example, pressing the A key could result in any of the following characters.

  • a
  • A
  • ГЎ (if the keyboard supports combining diacritics)

Further, if the ALT key is held down, pressing the A key produces ALT+A, which the system does not treat as a character at all, but rather as a system command.

Key Codes

When you press a key, the hardware generates a scan code. Scan codes vary from one keyboard to the next, and there are separate scan codes for key-up and key-down events. You will almost never care about scan codes. The keyboard driver translates scan codes into virtual-key codes. Virtual-key codes are device-independent. Pressing the A key on any keyboard generates the same virtual-key code.

In general, virtual-key codes do not correspond to ASCII codes or any other character-encoding standard. This is obvious if you think about it, because the same key can generate different characters (a, A, ГЎ), and some keys, such as function keys, do not correspond to any character.

That said, the following virtual-key codes do map to ASCII equivalents:

  • 0 through 9 keys = ASCII ‘0’ – ‘9’ (0x30 – 0x39)
  • A through Z keys = ASCII ‘A’ – ‘Z’ (0x41 – 0x5A)

In some respects this mapping is unfortunate, because you should never think of virtual-key codes as characters, for the reasons discussed.

The header file WinUser.h defines constants for most of the virtual-key codes. For example, the virtual-key code for the LEFT ARROW key is VK_LEFT (0x25). For the complete list of virtual-key codes, see Virtual-Key Codes. No constants are defined for the virtual-key codes that match ASCII values. For example, the virtual-key code for the A key is 0x41, but there is no constant named VK_A. Instead, just use the numeric value.

Key-Down and Key-Up Messages

When you press a key, the window that has keyboard focus receives one of the following messages.

The WM_SYSKEYDOWN message indicates a system key, which is a key stroke that invokes a system command. There are two types of system key:

The F10 key activates the menu bar of a window. Various ALT-key combinations invoke system commands. For example, ALT + TAB switches to a new window. In addition, if a window has a menu, the ALT key can be used to activate menu items. Some ALT key combinations do not do anything.

All other key strokes are considered nonsystem keys and produce the WM_KEYDOWN message. This includes the function keys other than F10.

When you release a key, the system sends a corresponding key-up message:

If you hold down a key long enough to start the keyboard’s repeat feature, the system sends multiple key-down messages, followed by a single key-up message.

In all four of the keyboard messages discussed so far, the wParam parameter contains the virtual-key code of the key. The lParam parameter contains some miscellaneous information packed into 32 bits. You typically do not need the information in lParam. One flag that might be useful is bit 30, the «previous key state» flag, which is set to 1 for repeated key-down messages.

As the name implies, system key strokes are primarily intended for use by the operating system. If you intercept the WM_SYSKEYDOWN message, call DefWindowProc afterward. Otherwise, you will block the operating system from handling the command.

Character Messages

Key strokes are converted into characters by the TranslateMessage function, which we first saw in Module 1. This function examines key-down messages and translates them into characters. For each character that is produced, the TranslateMessage function puts a WM_CHAR or WM_SYSCHAR message on the message queue of the window. The wParam parameter of the message contains the UTF-16 character.

As you might guess, WM_CHAR messages are generated from WM_KEYDOWN messages, while WM_SYSCHAR messages are generated from WM_SYSKEYDOWN messages. For example, suppose the user presses the SHIFT key followed by the A key. Assuming a standard keyboard layout, you would get the following sequence of messages:

WM_KEYDOWN: SHIFT
WM_KEYDOWN: A
WM_CHAR: ‘A’

On the other hand, the combination ALT + P would generate:

WM_SYSKEYDOWN: VK_MENU
WM_SYSKEYDOWN: 0x50
WM_SYSCHAR: ‘p’
WM_SYSKEYUP: 0x50
WM_KEYUP: VK_MENU

(The virtual-key code for the ALT key is named VK_MENU for historical reasons.)

The WM_SYSCHAR message indicates a system character. As with WM_SYSKEYDOWN, you should generally pass this message directly to DefWindowProc. Otherwise, you may interfere with standard system commands. In particular, do not treat WM_SYSCHAR as text that the user has typed.

The WM_CHAR message is what you normally think of as character input. The data type for the character is wchar_t, representing a UTF-16 Unicode character. Character input can include characters outside the ASCII range, especially with keyboard layouts that are commonly used outside of the United States. You can try different keyboard layouts by installing a regional keyboard and then using the On-Screen Keyboard feature.

Users can also install an Input Method Editor (IME) to enter complex scripts, such as Japanese characters, with a standard keyboard. For example, using a Japanese IME to enter the katakana character г‚« (ka), you might get the following messages:

WM_KEYDOWN: VK_PROCESSKEY (the IME PROCESS key)
WM_KEYUP: 0x4B
WM_KEYDOWN: VK_PROCESSKEY
WM_KEYUP: 0x41
WM_KEYDOWN: VK_PROCESSKEY
WM_CHAR: г‚«
WM_KEYUP: VK_RETURN

Читайте также:  Что за точка возле луны

Some CTRL key combinations are translated into ASCII control characters. For example, CTRL+A is translated to the ASCII ctrl-A (SOH) character (ASCII value 0x01). For text input, you should generally filter out the control characters. Also, avoid using WM_CHAR to implement keyboard shortcuts. Instead, use WM_KEYDOWN messages; or even better, use an accelerator table. Accelerator tables are described in the next topic, Accelerator Tables.

The following code displays the main keyboard messages in the debugger. Try playing with different keystroke combinations and see what messages are generated.

Miscellaneous Keyboard Messages

Some other keyboard messages can safely be ignored by most applications.

  • The WM_DEADCHAR message is sent for a combining key, such as a diacritic. For example, on a Spanish language keyboard, typing accent (‘) followed by E produces the character Г©. The WM_DEADCHAR is sent for the accent character.
  • The WM_UNICHAR message is obsolete. It enables ANSI programs to receive Unicode character input.
  • The WM_IME_CHAR character is sent when an IME translates a keystroke sequence into characters. It is sent in addition to the usual WM_CHAR message.

Keyboard State

The keyboard messages are event-driven. That is, you get a message when something interesting happens, such as a key press, and the message tells you what just happened. But you can also test the state of a key at any time, by calling the GetKeyState function.

For example, consider how would you detect the combination of left mouse click + ALT key. You could track the state of the ALT key by listening for key-stroke messages and storing a flag, but GetKeyState saves you the trouble. When you receive the WM_LBUTTONDOWN message, just call GetKeyState as follows:

The GetKeyState message takes a virtual-key code as input and returns a set of bit flags (actually just two flags). The value 0x8000 contains the bit flag that tests whether the key is currently pressed.

Most keyboards have two ALT keys, left and right. The previous example tests whether either of them of pressed. You can also use GetKeyState to distinguish between the left and right instances of the ALT, SHIFT, or CTRL keys. For example, the following code tests if the right ALT key is pressed.

The GetKeyState function is interesting because it reports a virtual keyboard state. This virtual state is based on the contents of your message queue, and gets updated as you remove messages from the queue. As your program processes window messages, GetKeyState gives you a snapshot of the keyboard at the time that each message was queued. For example, if the last message on the queue was WM_LBUTTONDOWN, GetKeyState reports the keyboard state at the moment when the user clicked the mouse button.

Because GetKeyState is based on your message queue, it also ignores keyboard input that was sent to another program. If the user switches to another program, any key presses that are sent to that program are ignored by GetKeyState. If you really want to know the immediate physical state of the keyboard, there is a function for that: GetAsyncKeyState. For most UI code, however, the correct function is GetKeyState.

Источник

Keyboard Checker the best online keyboard tester

Simply press any key on your keyboard to test it — if it works it will turn green

Looking for a replacement keyboard? Scroll down or click to see the keyboards we recommend

You can still press 86 keys

Press all regular keys for an easter egg

There is no difference between left and right Shift, Control, Alt, and Command or Windows.

Last key pressed none

Keys that work show up in green

Grey keys cannot be tested.

Press multiple keys at once to test for ghosting.

Toggle Hide Numpad

Click the button above to toggle the special keys.

The Numpad numbers are shown on the normal bar when tested.

Who is this site for?

It is, of course, for anyone with a keyboard who wants to test how well it works

However, there are some people this is particularly helpful for

Namely, hardware managers — people in charge of maintaining the stock of hardware, for examples in offices and schools

If you have to test 25 keyboards, it is a big help to use a site like this.

What may have been a job of a few hours can now be done in a matter of minutes.

When should you use this site?

If you want to check for ghosting.

If you want to know how many keys your computer or laptop’s keyboard can register at one time.

If you want to know whether your F1 to F12 keys still work, because that can be tricky to find out since you cannot just type them in a document.

Find out if the typing problems you’re having are due to software or hardware.

It doesn’t matter whether you’re using a Mac keyboard or a Windows keyboard, the keyboard test adapts automatically to your system.

Gaming Keyboard

Gaming keyboard for a very reasonable price.

Full-size keyboard with 6 configurable extra keys and media controls.

RGB lights can be configured specifically to your taste.

No need to install extra software; simply a solid gaming keyboard without having to spend a fortune.

Looking for a new keyboard?

Check out the four keyboards we recommend.

Honest recommendations: We only chose keyboards we would actually buy ourselves.

For each category we picked the keyboard we thought is best at a fair price.

Apple Keyboard

Official Mac keyboard, updated recently.

Has all Apple function keys, is small and light but very robust.

Читайте также:  Изображение каин авель луна

Remarkable build quality, stylish but clearly built to last.

Also works well with iPads and iPhones, and Windows computers.

If you want to save some money, get the previous edition . I am using this one myself, it types exactly like last gen MacBook Pros.

Illuminated Keyboard

Excellent all-round full-sized keyboard with illuminated keys for a great price.

Praised for being very comfortable, with an added palm-rest for ergonomics.

High quality, one reviewer said he used his for nearly 8 years without breaking.

About our Keyboard Test

We made this website simply to help people test keyboards.

We tried to make it as user-friendly as possible.

If you have any feedback, let us now on Twitter via @Keyboardchecker.

Wireless Keyboard

Never worry about changing the batteries of this wireless keyboard, because it charges using solar energy.

Even charges in rooms without much light.

The typing experience is very pleasant, similar to the MacBook Pro.

Источник

Using your keyboard

Whether you’re writing a letter or calculating numerical data, your keyboard is the main way to enter information into your computer. But did you know you can also use your keyboard to control your computer? Learning a few simple keyboard commands(instructions to your computer) can help you work more efficiently.

How the keys are organized

The keys on your keyboard can be divided into several groups based on function:

Typing (alphanumeric) keys. These keys include the same letter, number, punctuation, and symbol keys found on a traditional typewriter.

Control keys. These keys are used alone or in combination with other keys to perform certain actions. The most frequently used control keys are Ctrl, Alt, the Windows logo key , and Esc.

Function keys. The function keys are used to perform specific tasks. They are labeled as F1, F2, F3, and so on, up to F12. The functionality of these keys differs from program to program.

Navigation keys. These keys are used for moving around in documents or webpages and editing text. They include the arrow keys, Home, End, Page Up, Page Down, Delete, and Insert.

Numeric keypad. The numeric keypad is handy for entering numbers quickly. The keys are grouped together in a block like a conventional calculator or adding machine.

The following illustration shows how these keys are arranged on a typical keyboard. Your keyboard layout might be different.

Typing text

Whenever you need to type something in a program, e‑mail message, or text box, you’ll see a blinking vertical line ( ) called the cursor or insertion point. It shows where the text that you type will begin. You can move the cursor by clicking in the desired location with the mouse, or by using the navigation keys (see the «Using navigation keys» section of this article).

In addition to letters, numerals, punctuation marks, and symbols, the typing keys also include Shift, Caps Lock, Tab, Enter, the Spacebar, and Backspace.

Press Shift in combination with a letter to type an uppercase letter. Press Shift in combination with another key to type the symbol shown on the upper part of that key.

Press Caps Lock once to type all letters as uppercase. Press Caps Lock again to turn this function off. Your keyboard might have a light indicating whether Caps Lock is on.

Press Tab to move the cursor several spaces forward. You can also press Tab to move to the next text box on a form.

Press Enter to move the cursor to the beginning of the next line. In a dialog box, press Enter to select the highlighted button.

Press the Spacebar to move the cursor one space forward.

Press Backspace to delete the character before the cursor, or the selected text.

Using keyboard shortcuts

Keyboard shortcutsare ways to perform actions by using your keyboard. They’re called shortcuts because they help you work faster. In fact, almost any action or command you can perform with a mouse can be performed faster using one or more keys on your keyboard.

In Help topics, a plus sign (+) between two or more keys indicates that those keys should be pressed in combination. For example, Ctrl + A means to press and hold Ctrl and then press A. Ctrl + Shift + A means to press and hold Ctrl and Shift and then press A.

Find program shortcuts

You can do things in most programs by using the keyboard. To see which commands have keyboard shortcuts, open a menu. The shortcuts (if available) are shown next to the menu items.

Keyboard shortcuts appear next to menu items.

Choose menus, commands, and options

You can open menus and choose commands and other options using your keyboard. In a program that has menus with underlined letters, press Alt and an underlined letter to open the corresponding menu. Press the underlined letter in a menu item to choose that command. For programs that use the ribbon, such as Paint and WordPad, pressing Alt overlays (rather than underlines) a letter that can be pressed.

Press Alt + F to open the File menu, then press P to choose the Print command.

This trick works in dialog boxes too. Whenever you see an underlined letter attached to an option in a dialog box, it means you can press Alt plus that letter to choose that option.

Useful shortcuts

The following table lists some of the most useful keyboard shortcuts. For a more detailed list, see Keyboard shortcuts.

Windows logo key

Open the Start menu

Switch between open programs or windows

Close the active item, or exit the active program

Читайте также:  Луна во 2 доме у женщины соляр

Save the current file or document (works in most programs)

Copy the selected item

Cut the selected item

Paste the selected item

Select all items in a document or window

Display Help for a program or Windows

Windows logo key + F1

Display Windows Help and Support

Cancel the current task

Open a menu of commands related to a selection in a program. Equivalent to right-clicking the selection.

Using navigation keys

The navigation keys allow you to move the cursor, move around in documents and webpages, and edit text. The following table lists some common functions of these keys.

Left Arrow, Right Arrow, Up Arrow, or Down Arrow

Move the cursor or selection one space or line in the direction of the arrow, or scroll a webpage in the direction of the arrow

Move the cursor to the end of a line or move to the top of a webpage

Move the cursor to the end of a line or move to the bottom of a webpage

Move to the top of a document

Move to the bottom of a document

Move the cursor or page up one screen

Move the cursor or page down one screen

Delete the character after the cursor, or the selected text; in Windows, delete the selected item and move it to the Recycle Bin

Turn Insert mode off or on. When Insert mode is on, text that you type is inserted at the cursor. When Insert mode is off, text that you type replaces existing characters.

Using the numeric keypad

The numeric keypad arranges the numerals 0 though 9, the arithmetic operators + (addition), — (subtraction), * (multiplication), and / (division), and the decimal point as they would appear on a calculator or adding machine. These characters are duplicated elsewhere on the keyboard, of course, but the keypad arrangement allows you to rapidly enter numerical data or mathematical operations with one hand.

To use the numeric keypad to enter numbers, press Num Lock. Most keyboards have a light that indicates whether Num Lock is on or off. When Num Lock is off, the numeric keypad functions as a second set of navigation keys (these functions are printed on the keys next to the numerals or symbols).

You can use your numeric keypad to perform simple calculations with Calculator.

Open Calculator by clicking the Start button . In the search box, type Calculator, and then, in the list of results, click Calculator.

Check your keyboard light to see if Num Lock is on. If it isn’t, press Num Lock.

Using the numeric keypad, type the first number in the calculation.

On the keypad, type + to add, — to subtract, * to multiply, or / to divide.

Type the next number in the calculation.

Press Enter to complete the calculation.

So far, we’ve discussed almost every key you’re likely to use. But for the truly inquisitive, let’s explore the three most mysterious keys on the keyboard: PrtScn, Scroll Lock, and Pause/Break.

PrtScn (or Print Screen)

A long time ago, this key actually did what it says—it sent the current screen of text to your printer. Nowadays, pressing PrtScn captures an image of your entire screen (a «screen shot») and copies it to the Clipboard in your computer’s memory. From there you can paste it (Ctrl + V) into Microsoft Paint or another program and, if you want, print it from that program.

More obscure is SYS RQ, which shares the key with PrtScn on some keyboards. Historically, SYS RQ was designed to be a «system request,» but this command is not enabled in Windows.

Tip: Press Alt + PrtScn to capture an image of just the active window, instead of the entire screen.

ScrLk (or Scroll Lock)

In most programs, pressing Scroll Lock has no effect. In a few programs, pressing Scroll Lock changes the behavior of the arrow keys and the Page Up and Page Down keys; pressing these keys causes the document to scroll without changing the position of the cursor or selection. Your keyboard might have a light indicating whether Scroll Lock is on.

This key is rarely used. In some older programs, pressing this key pauses the program or, in combination with Ctrl, stops it from running.

Some modern keyboards come with «hot keys» or buttons that give you quick, one-press access to programs, files, or commands. Other models have volume controls, scroll wheels, zoom wheels, and other gadgets. For details about these features, check the information that came with your keyboard or computer, or go to the manufacturer’s website.

Tips for using your keyboard safely

Using your keyboard properly can help avoid soreness or injury to your wrists, hands, and arms, particularly if you use your computer for long periods. Here are a few tips to help improve keyboard use:

Place your keyboard at elbow level. Your upper arms should be relaxed at your sides.

Center your keyboard in front of you. If your keyboard has a numeric keypad, you can use the spacebar as the centering point.

Type with your hands and wrists floating above the keyboard, so that you can use your whole arm to reach for distant keys instead of stretching your fingers.

Avoid resting your palms or wrists on any type of surface while typing. If your keyboard has a palm rest, use it only during breaks from typing.

While typing, use a light touch and keep your wrists straight.

When you’re not typing, relax your arms and hands.

Take short breaks from computer use every 15 to 20 minutes.

Источник

Adblock
detector