haiku-website/static/legacy-docs/bebook/TheKeyboard_Definitions.html

84 lines
13 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - Special Topics - The Keyboard</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheKeyboard.html" title="The Keyboard" /><link rel="prev" href="TheKeyboard_Introduction.html" title="Introduction" /><link rel="next" href="TheKeyboard_ModifierKeys.html" title="Modifier Keys" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="TheKeyboard_Introduction.html" title="Introduction"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheKeyboard.html" title="The Keyboard"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="TheKeyboard_ModifierKeys.html" title="Modifier Keys"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - Special Topics - The Keyboard</div></div><div id="headerB">Prev: <a href="TheKeyboard_Introduction.html">Introduction</a>  Up: <a href="TheKeyboard.html">The Keyboard</a>  Next: <a href="TheKeyboard_ModifierKeys.html">Modifier Keys</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheKeyboard_Definitions"></a>Definitions</h2></div></div></div><p>This section lists and describes the keyboard terms and concepts that
you should be familiar with.</p><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheKeyboard_Definitions_KeyCodes"></a>Key Codes</h3></div></div></div><p>Keyboards come in a variety of styles and sizes, with different numbers
of keys on them, sometimes in different positions. Some special keys or
symbols even appear more than once on the same keyboard—for
example, most keyboards have two <span class="keycap">Enter</span> keys (sometimes one or both of
them is called <span class="keycap">Return</span>). Most keyboards have
two <span class="keycap">Shift</span> keys, and many have
two keys that can generate the "=" character—one of them on the
numeric keypad.</p><p>Each of these keys is unique as far as the hardware is concerned, even if
they usually generate the same result as far as the user is concerned.
Because of this, each key has a unique number, called a key code. This is
a numeric byte value between 0x01 and 0x7F. They're not the same as the
<acronym class="acronym">ASCII</acronym> or
<a class="link" href="http://www.unicode.org"><span class="trademark">Unicode</span></a>
values for the characters generated by the
keys—which makes sense, since not every key generates a character.</p><p>For example, the left <span class="keycap">Shift</span> key has the key code value of 0x4B, and the
right <span class="keycap">Shift</span> key has the key code of 0x56. Neither of these generates a
<code class="constant">B_KEY_UP</code> event (although they do generate a <code class="constant">B_MODIFIERS_CHANGED</code> event).
The additional implication here is clear: software can actually tell the
difference between these two keys—and any other keys that generate
the same Unicode value—if they need to do so.</p><p>It's also important to note that key codes don't differentiate between
shifted and unshifted keys. Pressing <span class="keycap">A</span> generates the key code 0x27
whether the <span class="keycap">Caps Lock</span> or <span class="keycap">Shift</span> key is down or not.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheKeyboard_Definitions_TheKeymap"></a>The Keymap</h3></div></div></div><p>Most software written these days expects keys to be received in either
<acronym class="acronym">ASCII</acronym> or Unicode format (or, in the case of BeOS, in <acronym class="acronym">UTF-8</acronym> format, which
is a form of Unicode in which the <acronym class="acronym">ASCII</acronym> codes are contained). So
obviously receiving a value of 0x27 for the <span class="keycap">A</span> key isn't going to help a
program that expects to receive 0x41, the <acronym class="acronym">UTF-8</acronym> value for the character
"A".</p><p>So clearly the key codes the input server add-on obtains from the
keyboard device need to be translated into <acronym class="acronym">UTF-8</acronym>. This is done by using a
keymap. This is a table that can be used to look up a key code and
determine, based on which modifier keys are currently engaged, the <acronym class="acronym">UTF-8</acronym>
bytes that should be generated. It also defines which keys are treated as
modifier keys.</p><p>BeOS maintains a keymap for use by all applications. Applications that
want to look up key codes in the keymap can call
<a class="link" href="TheInputServer_Functions.html#get_key_map" title="get_key_map()"><code class="function">get_key_map()</code></a>
to get a copy of it. The Keymap preference panel can be used to configure the
system keymap.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheKeyboard_Definitions_CharacterKeys"></a>Character Keys</h3></div></div></div><p>A character key is a key that's mapped to a particular <acronym class="acronym">UTF-8</acronym> byte or byte
sequence. For example, in the standard American keymap, the key labeled
<span class="keycap">A</span> is mapped to the letter "a" when pressed with no modifier keys down,
"A" when the <span class="keycap">Caps Lock</span> or a <span class="keycap">Shift</span>
key is down, and
<span class="keycap">control</span>+<span class="keycap">A</span>
(<acronym class="acronym">UTF-8</acronym> code
0x01) when the <span class="keycap">Control</span> key is down. Mapped character keys generate
<code class="constant">B_KEY_DOWN</code> and <code class="constant">B_KEY_UP</code>
messages when they're pressed and released.</p><p>Keys that aren't mapped to characters generate <code class="constant">B_UNMAPPED_KEY_DOWN</code> and
<code class="constant">B_UNMAPPED_KEY_UP</code> messages.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheKeyboard_Definitions_ModifierKeys"></a>Modifier Keys</h3></div></div></div><p>Modifier keys set states that affect the way character keys are
interpreted. Some modifier keys, such as <span class="keycap">Caps Lock</span>, toggle in and out of
a locked-on or locked-off position each time they're pressed. Others,
like Shift, set the state only as long as they're held down.</p><p>The keymap contains lists of how to interpret each key depending on which
modifier keys are currently engaged.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheKeyboard_Definitions_TheScrollLockKey"></a>The Scroll Lock Key</h3></div></div></div><p>The <span class="keycap">Scroll Lock</span> key is unique. In the standard keyboard Input Server
add-on, it both generates a character and sets a modifier state.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheKeyboard_Definitions_RepeatingKeys"></a>Repeating Keys</h3></div></div></div><p>When a key is pressed and held down, it produces a continuous series of
<code class="constant">B_KEY_DOWN</code> or <code class="constant">B_UNMAPPED_KEY_DOWN</code>
messages, as long as the key is still
held down and doesn't press another key. After the first message, there's
a slight delay before the key begins repeating. This delay can be
determined by calling
<a class="link" href="TheInputServer_Functions.html#get_key_repeat_delay"><code class="function">get_key_repeat_delay()</code></a>
and can be changed by calling
<a class="link" href="TheInputServer_Functions.html#set_key_repeat_delay"><code class="function">set_key_repeat_delay()</code></a>
(although you should leave the user's preference for this alone).</p><p>After the key begins to repeat, the <code class="constant">B_KEY_DOWN</code>
or <code class="constant">B_UNMAPPED_KEY_DOWN</code>
messages are sent at a fixed rate; this rate can be determined by calling
<a class="link" href="TheInputServer_Functions.html#get_key_repeat_rate"><code class="function">get_key_repeat_rate()</code></a>.</p><p>All keys repeat except
<span class="keycap">Pause</span>, <span class="keycap">Break</span>, <span class="keycap">Caps Lock</span>,
<span class="keycap">Num Lock</span>, and <span class="keycap">Scroll Lock</span>.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheKeyboard_Definitions_DeadKeys"></a>Dead Keys</h3></div></div></div><p>Dead keys don't generate characters until the user strikes another key.
If the key the user presses after the dead key is in a particular set,
the two keys together produce one key-down event (and, usually, one
character). If the second keystroke isn't in that set, two key-down
events are generated.</p><p>Dead keys are only dead when certain prescribed modifiers (by default,
just the Option key) are held down. They're most appropriate when the
character to be generated can be thought of as being composed of two
distinguishable parts—such as "a" and "e"
combining into "æ".</p><p>The system permits up to five dead keys. By default, they're reserved for
combining diacritical marks with other characters. The diacritical marks
are the acute (´) and grave (`) accents, dieresis (¨), circumflex
(^), and tilde (~).</p></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="TheKeyboard_Introduction.html">Introduction</a>  Up: <a href="TheKeyboard.html">The Keyboard</a>  Next: <a href="TheKeyboard_ModifierKeys.html">Modifier Keys</a> </div><div id="footerB"><div id="footerBL"><a href="TheKeyboard_Introduction.html" title="Introduction"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheKeyboard.html" title="The Keyboard"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="TheKeyboard_ModifierKeys.html" title="Modifier Keys"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>