keypress and keyup – why is the keyCode different?

The events are for completely different purposes. Use keyup and keydown for identifying physical keys and keypress for identifying typed characters. The two are fundamentally different tasks with different events; don’t try to mix the two. In particular, keyCode on keypress events is usually redundant and shouldn’t be used (except in older IE, but see … Read more

How to add done button on keyboard on top of keyboard in IOS?

Hope this help 🙂 UIToolbar* keyboardToolbar = [[UIToolbar alloc] init]; [keyboardToolbar sizeToFit]; UIBarButtonItem *flexBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; UIBarButtonItem *doneBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(yourTextViewDoneButtonPressed)]; keyboardToolbar.items = @[flexBarButton, doneBarButton]; self.yourTextView.inputAccessoryView = keyboardToolbar; and then add yourTextViewDoneButtonPressed method -(void)yourTextViewDoneButtonPressed { [self.yourTextView resignFirstResponder]; }

Xcode/iOS5: Move UIView up, when keyboard appears

To move the view up, just change its center. First, keep the original one in a CGPoint property. – (void)viewDidLoad { … self.originalCenter = self.view.center; … } Then, change as needed when keyboard shows up: self.view.center = CGPointMake(self.originalCenter.x, /* new calculated y */); Finally, restore it when keyboard is hidden: self.view.center = self.originalCenter; Add animation … Read more

Where can I find a list of key codes for use with Cocoa’s NSEvent class?

Here you go. It’s a map of all the virtual key-codes on the US extended keyboard layout, from the old Inside Macintosh: Text. Most of the key codes are still currently, although I suspect that the very newest Apple keyboards—those with media keys—may have changed a few of the function keys. Note: ISO and non-extended … Read more

iPhone keyboard, Done button and resignFirstResponder

I made a small test project with just a UITextField and this code #import <UIKit/UIKit.h> @interface TextFieldTestViewController : UIViewController <UITextFieldDelegate> { UITextField *textField; } @property (nonatomic, retain) IBOutlet UITextField *textField; @end #import “TextFieldTestViewController.h” @implementation TextFieldTestViewController @synthesize textField; – (void)viewDidLoad { [self.textField setDelegate:self]; [self.textField setReturnKeyType:UIReturnKeyDone]; [self.textField addTarget:self action:@selector(textFieldFinished:) forControlEvents:UIControlEventEditingDidEndOnExit]; [super viewDidLoad]; } – (IBAction)textFieldFinished:(id)sender { // … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)