Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3317292
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:34:14+00:00 2026-05-17T22:34:14+00:00

I have subclassed NSWindow in a NSDocument application in order to receive keyDown events.

  • 0

I have subclassed NSWindow in a NSDocument application in order to receive keyDown events.

I have used the following code in my subclasss…

- (void)keyDown:(NSEvent *)theEvent {

    NSLog(@"keyDown!");

    if ([theEvent modifierFlags] & NSAlternateKeyMask) {
        NSLog(@"Alt key Down!");
    }
    else
        [super keyDown:theEvent];
}

I’m receiving key events when non-modifier keys are pressed!
I’m also receiving “Alt Key is Down” when I press alt+z for example (alt+non-modifierkey).

The issue here is that I want to handle the event when just the alt/option key is pressed alone, without in combination with other keys and -keyDown: does not get called! What am I missing ?

Thanks…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:34:15+00:00Added an answer on May 17, 2026 at 10:34 pm

    You could catch the Alt/Option key alone in -flagsChanged: instead of -keyDown:.

    -(void)flagsChanged:(NSEvent*)theEvent {
        if ([theEvent modifierFlags] & NSAlternateKeyMask) {
            NSLog(@"Alt key Down (again)!");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following class: <?php /* * Abstract class that, when subclassed, allows
I have subclassed Form to include some extra functionality, which boils down to a
I have subclassed java.awt.Frame and have overridden the paint() method as I wish to
I have an abstract Class Monitor.java which is subclassed by a Class EmailMonitor.java .
I have an NSWindow that I defined in interface builder. I want to make
I have an NSWindow subclass (GameWindow) containing an NSOpenGLView subclass (GameView). The app is
I have an NSBorderlessWindow subclass of NSWindow with a transparent and non-opaque background (so
I have subclassed View and do some bitmap drawing inside of the onDraw method.
I have subclassed UITableViewCell to make a custom cell for a tableView. I add
I have the following situation: A UIScrollView contains a UIWebView. I want the content

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.