• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Key Check at Startup
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Key Check at Startup


  • Subject: Re: Key Check at Startup
  • From: David Remahl <email@hidden>
  • Date: Wed, 19 Jun 2002 21:16:56 +0200

> Hi List!
> I want my app to check whether the option key is pressed at startup.
> I searched the Documentation, but I haven9t found anything. I9d be glad to
> further tell you something about it but I don9t know anything. I hope this
> makes sense...
>
> Thanks,
> Martin

This has been mentioned a few times on the list before. You will have to use
Carbon to get the state of a modifier without having an NSEvent to play
with. Here is a category to do it.

/ Regards, David Remahl

---

#import "NSEvent-CarbonAdditions.h"
#import <Carbon/Carbon.h>

@implementation NSEvent (ModifierKeys)

+ (BOOL) isControlKeyDown
{
return (GetCurrentKeyModifiers() & controlKey) != 0;
}

+ (BOOL) isOptionKeyDown
{
return (GetCurrentKeyModifiers() & optionKey) != 0;
}

+ (BOOL) isCommandKeyDown
{
return (GetCurrentKeyModifiers() & cmdKey) != 0;
}

+ (BOOL) isShiftKeyDown
{
return (GetCurrentKeyModifiers() & shiftKey) != 0;
}

@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Key Check at Startup
      • From: Martin Weil <email@hidden>
References: 
 >Key Check at Startup (From: Martin Weil <email@hidden>)

  • Prev by Date: Key Check at Startup
  • Next by Date: Re: Key Check at Startup
  • Previous by thread: Key Check at Startup
  • Next by thread: Re: Key Check at Startup
  • Index(es):
    • Date
    • Thread