DAVEd
DAVEd

Reputation: 51

How to press the keys on keyboard without using keyboard in Objective-C?

I want my program to press certain keys on my keyboard without me doing it physically. for example, button in my app for (command + UP) if user press the button, my app will do same thing in the keyboard . How i do this?

Upvotes: 0

Views: 558

Answers (2)

markhunte
markhunte

Reputation: 6932

I am assuming it is that you have linked a menu item to an IBAction IN Interface Builder and given it a short cut of command+ up. If so just link your button to the same action

edit* Have a look at these.

Xcode 4 xcode_help-interface_builder help including video examples

xcode 3 - Interface Builder User Guide pdf look at chapter 7. ( I could not find the guide on apples site, it all points to v4?)

Upvotes: 0

Lukman
Lukman

Reputation: 19119

I'm assuming that you have a function that will be triggered when the user presses the command + up keys. So to illustrate:

  command + up ---> call function

And you are asking is there a way to:

  click a button ---> somehow trigger command + up event ---> call function

But why not you just do:

  click a button ---> call function

Much simpler and more straight-forward. Is there any specific reason you still need the command + up event triggered?

Upvotes: 2

Related Questions