AppKit/Platform/DOM/CPPlatformWindow+DOMKeys.j File Reference

Go to the source code of this file.

Variables

 CPKeyCodes
CPKeyCodes firesKeyPressEvent

Variable Documentation

Definition at line 25 of file CPPlatformWindow+DOMKeys.j.

Initial value:
 function(keyCode, opt_heldKeyCode, opt_shiftKey, opt_ctrlKey, opt_altKey) 
{
    if (!CPFeatureIsCompatible(CPJavascriptRemedialKeySupport))
        return true;

    if (CPBrowserIsOperatingSystem(CPMacOperatingSystem) && opt_altKey) 
        return CPKeyCodes.isCharacterKey(keyCode);

    
    if (opt_altKey && !opt_ctrlKey)
        return false;

    
    if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine) && !opt_shiftKey && (opt_ctrlKey || opt_altKey))
        return false;

    
    
    if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine) && opt_ctrlKey && opt_heldKeyCode == keyCode)
        return false;

    switch (keyCode)
    {
        case CPKeyCodes.ENTER: return true;
        case CPKeyCodes.ESC:   return !CPBrowserIsEngine(CPWebKitBrowserEngine);
    }

    return CPKeyCodes.isCharacterKey(keyCode);
}

Returns true if the key fires a keypress event in the current browser.

Accoridng to MSDN [1] IE only fires keypress events for the following keys:

  • Letters: A - Z (uppercase and lowercase)
  • Numerals: 0 - 9
  • Symbols: ! @ # $ % ^ & * ( ) _ - + = < [ ] { } , . / ? \ | ' ` ~
  • System: ESC, SPACEBAR, ENTER

That's not entirely correct though, for instance there's no distinction between upper and lower case letters.

[1] http://msdn2.microsoft.com/en-us/library/ms536939(VS.85).aspx)

Safari is similar to IE, but does not fire keypress for ESC.

Additionally, IE6 does not fire keydown or keypress events for letters when the control or alt keys are held down and the shift key is not. IE7 does fire keydown in these cases, though, but not keypress.

Parameters:
keyCode A key code.
opt_heldKeyCode Key code of a currently-held key.
opt_shiftKey Whether the shift key is held down.
opt_ctrlKey Whether the control key is held down.
opt_altKey Whether the alt key is held down.
Returns:
Returns YES if it's a key that fires a keypress event.

Definition at line 159 of file CPPlatformWindow+DOMKeys.j.


Generated on Fri Apr 9 11:04:19 2010 for Cappuccino API by  doxygen 1.6.1