1 Replies - 4950 Views - Last Post: 25 November 2013 - 09:19 AM

#1 Kez323   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-May 13

How to get a keyboard key when pressed?

Posted 12 May 2013 - 11:57 AM

Language: Objective c
App Used: Xcode
Platform: OS X
Hey, im wanting to understand how to use keyboard keys in my apps.
Like.. eg: if key "W" is clicked.. do x..

I've tried googling it, searching fourms, trying myself, but i just dont get it

i need help understanding how to get something to happen when a keyboard key is pressed in an application.. examples or helpful links maybe?
Is This A Good Question/Topic? 0
  • +

Replies To: How to get a keyboard key when pressed?

#2 tony12095   User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 109
  • Joined: 23-October 12

Re: How to get a keyboard key when pressed?

Posted 25 November 2013 - 09:19 AM

-(void)keyDown:(NSEvent *)event {
    NSString *characters;
    characters = [theEvent characters];
    unichar character;

    switch (character)
    {
        case 'd':
             //do something;
        default:
             break;
     }
}


This post has been edited by macosxnerd101: 25 November 2013 - 04:57 PM
Reason for edit:: Please use code tags

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1