<doc>
  <legacy_id>1700</legacy_id>
  <name>keyDown</name>
  <type>message</type>
  <syntax>
    <example>keyDown <i>keyName</i></example>
  </syntax>
  <library></library>
  <objects>
  </objects>
  <synonyms>
  </synonyms>
  <classification>
    <category>User Interaction</category>
  </classification>
  <references>
    <command tag="focus">focus Command</command>
    <function tag="keysDown">keysDown Function</function>
    <message tag="enterInField">enterInField Message</message>
    <message tag="controlKeyDown">controlKeyDown Message</message>
    <message tag="functionKey">functionKey Message</message>
    <message tag="optionKeyDown">optionKeyDown Message</message>
    <message tag="escapeKey">escapeKey Message</message>
    <property tag="powerKeys">powerKeys Property</property>
    <property tag="emacsKeyBindings">emacsKeyBindings Property</property>
    <property tag="extendKey">extendKey Property</property>
  </references>
  <history>
    <introduced version="1.0">Added.</introduced>
  </history>
  <platforms>
    <mac/>
    <windows/>
    <linux/>
    <ios/>
    <android/>
  </platforms>
  <classes>
    <desktop/>
    <server/>
    <web/>
    <mobile/>
  </classes>
  <security>
  </security>
  <summary>Sent when the user presses a key.</summary>
  <examples>
    <example>on keyDown theKey </p><p>  if theKey is not a number then beep</p><p>  else pass keyDown</p><p>end keyDown</example>
  </examples>
  <description>
    <p>Handle the <b>keyDown</b> <keyword tag="message box">message</keyword> if you want to do something special when the user presses any key or a particular key you check for in the <glossary tag="handler">handler</glossary>.</p><p/><p><b>Parameters:</b></p><p>The <i>keyName</i> is the actual <keyword tag="character">character</keyword> of the pressed key.</p><p/><p><b>Comments:</b></p><p>The message is sent to the active (focused) control, or to the current card if no control is focused.</p><p/><p>If the key pressed is the Return, Tab, Backspace, Delete, or Enter key, an arrow key, or a function key, no <b>keyDown</b> <keyword tag="message box">message</keyword> is sent. Instead, the <message tag="returnKey">returnKey</message>, <message tag="tabKey">tabKey</message>, <message tag="backspaceKey">backspaceKey</message>, <message tag="deleteKey">deleteKey</message>, <message tag="enterKey">enterKey</message>, <message tag="arrowKey">arrowKey</message>, or <message tag="functionKey">functionKey</message> <keyword tag="message box">message</keyword> is sent.</p><p/><p>If the insertion point is in a field, the entry of typed characters is triggered by the <b>keyDown</b> <keyword tag="message box">message</keyword>. This means that <glossary tag="trap">trapping</glossary> the <b>keyDown</b> <keyword tag="message box">message</keyword> and not <glossary tag="pass">passing</glossary> it prevents typing from being entered in the <keyword tag="field">field</keyword>.</p><p/><p><b>Note:</b> The <b>keyDown</b> <keyword tag="message box">message</keyword> is sent before the <keyword tag="character">character</keyword> is placed in the <keyword tag="field">field</keyword>, so if you need to use the new content of the <keyword tag="field">field</keyword>, handle the <message tag="keyUp">keyUp</message> <keyword tag="message box">message</keyword> instead.</p><p/><p><b>Note:</b> The <b>keydown</b> message is not sent when either of the <i>Option</i>, <i>Control</i> or <i>Command</i> keys are down. In this case, first a  <message tag="rawKeyDown">rawKeyDown message</message> is sent, then one of <message tag="optionKeyDown">optionKeyDown</message>, <message tag="controlKeyDown">controlKeyDown</message> or <message tag="commandKeyDown">commandKeyDown</message> is sent instead of <b>keydown</b>.</p><p> </p>
  </description>
</doc>