Detect any key, including modifier keys, on OS X

I need to detect all the keys that the user presses. Using -keyDown: I can get most key presses (alphanumeric, function keys, arrows, space bar, escape, return), but I cannot get any modifier key when it's pressed alone. How do I detect absolutely an

How to capture Unicode from key events without NSTextView

I'd like to capture key events from any window in the application and interpret them as Unicode. For example, if the user types Option-e-e (on a default-configured US English keyboard), I would like to recognize that as "é". I tried capturing ke

Remove mouse events on NSWindow based on the click position

Let's say I have a floating, borderless, circular NSWindow. It is circular because the content view simply draws a red circle. That content view needs to be layer-backed ([contentView setWantsLayer:YES]), because I'm applying CoreAnimations on it, e.

Obtaining the Key-down Event in an NSView Controller

I'm trying to find a solution that allows me to get keydown events in a view controller. I do not believe a view controller is part of the responder chain by default. I would appreciate a sample of how to go about this. I have had trouble finding doc

Map NSEvent keyCode to virtual key code

NSEvent keyCode gives a keyboard scan code, which is a hardware specific code representing the physical key. I want to convert the scan code to a virtual key code, which is the logical key based on the users keyboard layout (QWERTY, AZERTY, etc). In

How can you capture modifier keys exclusively?

When using NSEvent flagsChanged and ANDing the flags with various KeyMasks, how can you test themin an exclusive way? Currently, using a series of if else conditions whit the pattern: if ((flags & someKeyMask) && (flags someOtherKeyMask)) This

How to stop listening to NSEvents?

I have a problem with listening for events, I can listen for events which works perfectly however I can't make it stop listening to events. I researched it for a while and came up with the a method, + (void)removeMonitor:(id)eventMonitor, that it say

Incorrect location using [NSEvent mouseLocation]

I make a iphone remote mouse controller application for Mac: the iPhone application sends the coordinate values to the Mac, which then processes mouse location value. To get the current mouse location on the Mac, the receiver calls [NSEvent mouseLoca

Receiving a Double-Click Event

I've been searching the Apple docs and the only function I could find pertaining to a double click just returned the acceptable time between clicks for it to be considered a double click. Can someone please show me an example of a double click event?

NSTextfield + NSMenu and first responder

I'm trying to implement my own autocomplemention system (result is pull from an sqlite database) I've set up a NSTextField and the appropriate delegate. Each time the text in the NSTextField change, it call - (void)controlTextDidChange:(NSNotificatio

Change NSEvent to send a different key than pressed

I'm trying to create an OS X keyboard hook for assistive technology purposes (i.e. don't worry, not a keylogger). When a user presses a key, I want to prevent the real keypress and send a fake keypress (character of my choosing) instead. I have the f

Detecting whether a window is dragged

Is there a way (without using any undocumented API) to figure out if ANY window (not just the application from which the code is running from) is being dragged? I can use [NSEvent addGlobalMonitorForEventsMatchingMask:] but this is just for general d

How to manage key events on iphone

Hi I am working on an iphone application and want to handle keyboard events in iphone. In Mac, there is a class NSEvent which handles both keyboard and mouse events, and in ios (iphone/ipad) the counterpart of NSEvent is UIEvent which handles only to

Cocoa - NSEvent Answer the SHIFT key?

I was wondering if NSEvent responds to the "Shift" key on the keyboard. I am logging the keyCodes when debugging my app and I don't get a keyCode value for the shift key. Thanks, Kevin EDIT: This is the code I am using from a user response. -(vo

NSMenu pressed the mouse button in 10.5

I'm updating (downdating?) an application I've written for 10.6+ to work in 10.5+. I'm struggling with capturing the currently pressed mouse button in the -(void)menuWillOpen:(NSMenu *); selector. For 10.6+ I'm taking advantage of the [NSEvent presse

NSEvent power to the system

Can someone show an example on how to create an NSEvent that simulates pressing return?You should take a look at the NSEvent Class Reference, and more specifically, -keyEventWithType:location:modifierFlags:timestamp:windowNumber:context:characters:ch

NSButton Mousedown Event

I'm trying to show a pop up menu on mouse down on a button. The button should appear pressed while mouse down, and be "un pressed" on mouse up regardless of any of the menu item been selected. Similar to the Expose/Space Preference panel "+