I'm looking for two numbers here: the height in portrait and the height in landscape. Don't answer in cm or inches, but rather in pixels.
-
2You can easily make two screenshots and measure. – Eiko Nov 18 '10 at 10:42
-
2OP please change the correct answer to one of the answers that determines the frame programmatically. Also, you cannot specify pixels, but rather points on iOS. – Dan Rosenstark May 27 '12 at 15:31
-
If you are looking for height, but not the programmatically found height, then this is a poorly worded question. Do you want the English Keyboard? Spilt keyboard? Height with autofill enabled? Or even the new iOS 8 keyboards? Plus, if you don't want a programatic answer, don't ask the question on stackoverflow. Most developers that come across this question and the accepted answer are going to be misguided. From a development standpoint, you should always find the height programmatically. From a design standpoint, find a pixel ruler and measure it. – Barlow Tucker Oct 06 '14 at 22:57
-
possible duplicate of [iPad keyboard dimensions](http://stackoverflow.com/questions/2743140/ipad-keyboard-dimensions) – Gordon Tucker Oct 30 '14 at 17:34
13 Answers
The portrait height is 264 while the landscape height is 352.
I know this is a late answer, but I just came across this question myself.

- 7,991
- 6
- 35
- 54
-
Don't worry about the answer being late. I will accept this answer as soon as I've validated the height. :) – Erik B Dec 24 '10 at 07:26
-
This is correct for the English keyboard. Sorry for not validating the height sooner. – Erik B Mar 31 '11 at 21:42
-
8This is a bad answer. You never want to hard code these pixel values because they could be changed in future releases. For example, Apple could tweak the dimensions of the keyboards by a few pixels, they could introduce new forms of keyboard (such as the split keyboard) or different sizes for different languages. They could also release different resolution screens (such as the retina display). All these cases could cause the desired effect of your code to break. It would be much better to use one of the dynamic solutions offered by the other answers. – James Bedford May 28 '12 at 03:38
-
19@JamesBedford It's not a bad answer, it's the correct answer. You don't even know what I needed those measurements for. Perhaps I'm a graphics designer and need the height of the keyboard to draw a proper mockup. Hardcoding these values in an app may be bad practice, but it has nothing to do with the quality of the answer. – Erik B May 28 '12 at 11:02
-
Ok, fair point! I guess your question is very direct haha! I think we've both managed to make our points here. :) – James Bedford May 28 '12 at 12:03
-
1@LeonS, This answer is not incorrect. Your answer is for iPhone. This question is about the iPad. – Erik B Jul 01 '12 at 17:54
-
@ErikB I'm sorry to disagree but I'm with James on that one. This is like asking "what is the height of a human" and answering with a number of inches. It depends on a number of factors, none of which are outlined in the original question. It's not a bad answer per say but it is definitely not the correct answer - with all due respect. – foob.ar Oct 15 '15 at 16:14
-
1@foob.ar When this question was asked there was only one available iPad and the keyboard height did not differ between the available iOS versions. Different languages had different height keyboards, but the majority of all keyboards had the same height as the English keyboard. Today things are very different and the usefulness of this answer is much lower, but historically it had relevance as you can see by the number of upvotes. – Erik B Nov 06 '15 at 10:26
- (void) keyboardWasShown:(NSNotification *)nsNotification {
NSDictionary *userInfo = [nsNotification userInfo];
CGSize kbSize = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
NSLog(@"Height: %f Width: %f", kbSize.height, kbSize.width);
// Portrait: Height: 264.000000 Width: 768.000000
// Landscape: Height: 352.000000 Width: 1024.000000
}

- 12,720
- 7
- 52
- 72

- 577
- 4
- 4
-
1+1 for this answer- shows how the height is returned as what is supposed to be the width when in Landscape. I noticed I was getting a height of 1024 as height and 352 as width, in landscape, which seemed weird to me, until I saw this answer. Thanks – pnizzle Aug 27 '12 at 22:57
-
1
-
4
-
1This is why, because you need this: `[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardDidShowNotification object:nil];` However my problem is, this app is landscape and this code doesn't seem to take that into effect. It says my Height is 1024 and my width is 396. – thefoyer Jun 05 '14 at 19:46
-
@thefoyer - Did you ever figure out out what was happening with the landscape app? Seems to be fixed on iOS 8 but on iOS 7 I get the same issue and just assume the smallest dimensions is the height... kind of hacky but it seems to work. – Alex Argo Sep 02 '14 at 05:55
-
@Alex- Yeah, no I didn't I basically did the same thing if I remember correctly. – thefoyer Sep 04 '14 at 14:34
-
@Alex - Seems like the hack you suggested makes more sense. The one with the smaller dimension could be considered as height. At least can get rid of the iOS version specific check in the code.. – Swaroop S Mar 17 '15 at 06:51
-
If you enable the KeyboardAccessory view (undo/redo/autocomplete) then the keyboard frame height is more than 352. I get 398 on iPad2 with iOS 9. – foob.ar Oct 15 '15 at 16:05
The answer is: it depends.
I am aware of 16 different heights the keyboard can be, and it can be in any position.
It is different for:
- landscape/portrait,
- webview/non-webview,
- asian character selection style, regular language
- split keyboard / non-split
I have attached an image showing some different possible configurations.
Rather than enumerating all 16 possibilities, I think you want to observe UIKeyboardWillShowNotification
/UIKeyboardWillHideNotification
and UIKeyboardDidChangeFrameNotification
(iOS 5.0+), and then get the keyboard's frame from those events.

- 4,159
- 3
- 33
- 35
On the iPad, the keyboard size can also depend on the language (e.g. the japanese keyboard is taller). Another reason to query it programmatically.

- 189
- 2
-
Chinese keyboards are also taller, as they are words to choose from, based on input. – Raptor Nov 07 '13 at 07:54
You can get the keyboard height from the userInfo dictionary returned by the will/did show/hide keyboard notification, as provided by the UIWindow class (reference guide link). This is a much better way of getting the height than hard-coding because you get the following benefits:
- Device independence (iPhone/iPod or iPad)
- Resolution independence (iPhone 3G screen/retina display/iPad display/future displays).
- Keyboard type/style independence (different on-screen keyboards may have difference sizes).
In fact, the answers to this question that give an exact number most likely got this number by looking at the results returned within this dictionary!

- 28,702
- 8
- 57
- 64
-
1Sure, but snippets have already been provided by others so that's ok! :) – James Bedford May 28 '12 at 03:39
I've voted down a couple of answers on this page, as they are dangerously misleading.
Certainly, with iOS 8, you cannot use a hard-coded keyboard height.
Here's my app, running on an iPhone, to give my reason why.
Grab your ruler, and tell me, what is the height of the onscreen keyboard..?
Ahh... you can't do it, can you ?
The height can vary, if the user turns on the auto-type bar at the top of the onscreen keyboard (which, by the way, triggers off a second "keyboardWillShow
" event).
The same is true for the onscreen keyboard on the iPad.
Bottom line: sorry folks, you must measure the keyboard height in a keyboardWillShow
event.
You will hit problems otherwise.
- (void)keyboardWillShow:(NSNotification *)notification {
NSDictionary *info = [notification userInfo];
NSValue *kbFrame = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardFrame = [kbFrame CGRectValue];
keyboardFrame = [self.view convertRect:keyboardFrame fromView:nil];
CGFloat heightOfKeyboard = keyboardFrame.size.height;
NSLog(@"The keyboard is now %d pixels high.", (int)heightOfKeyboard);
}
Btw, don't forget that call to convertRect
in the code above.
Without it, I found that, on an iPad running in landscape with iOS 8, sometimes the keyboard would be reported as having a height of 1024 pixels..
Just one more thing...
Today, I was working on a custom control I'd written, which appears at the bottom of the iPhone/iPad screen, and realised I hadn't taken the onscreen keyboard height into consideration.
I didn't want to add keyboardWillShow/Hide notifications, as this little control was generic, able to be called from any of my screens.
My solution to find the height of the onscreen keyboard, if it was currently visible, was to use the excellent visibleKeyboardHeight function from the free SVProgressHUD
control.
That control also needed the height of the onscreen keyboard, so its notification message UIView
s would appear vertically-centered.
It worked a treat... so if you do need a quick'n'dirty method of grabbing the keyboard height, grab a copy of this code, and look in the SVProgressHUD.m file.

- 27,846
- 7
- 149
- 159
You can find this out programmatically (through the simulator if you dont have a device).

- 1,294
- 1
- 15
- 29
In iOS 7, for iPad it is 402 for Landscape and 314 for Portrait

- 319
- 2
- 9
-
It may be in your application & context but this is not a universal fact. See answers from @jcampbell1 and others. It depends on many things including language, accessory toolbar, 3rd party keyboards, etc. – foob.ar Oct 15 '15 at 16:09
Heights are: PORTRAIT = 264 LANDSCAPE = 352

- 383
- 4
- 9
-
This is the kind of answer I'm looking for. If you can provide the height in landscape I will accept it as my answer. :) – Erik B Dec 11 '10 at 15:22
-
The portrait height is 264 for the English keyboard, so your answer was incorrect, but thanks anyway. – Erik B Mar 31 '11 at 21:46
-
You are correct. Sorry. The way I measured them I wasn't taking into account the 20 px of the status bar. I've updated my answer now. – bornbnid Apr 13 '11 at 18:32
There was an issue in iOS 7 where the height and width were not swapping in landscape mode, but the issue was fixed in iOS 8.
So, here is the piece of code that would always return the height for iOS7 or iOS8, thereby eliminating the version specific check in your code.
- (void)keyboardWasShown:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
//Always gives the height as the height is of smaller dimension
CGFloat height = (kbSize.height>kbSize.width)?kbSize.width:kbSize.height;
}

- 490
- 5
- 11
I think there are more troubles than are solved in others answers. For example, you can end up with this keyboard:
This happens when you click "hide" button on iPad keyboard on iOS 9. This keyboard has still full
size in notification info from Mike Gledhill
answer. (in UIKeyboardFrameEndUserInfoKey
height of keyboard is higher than 300).
I had to subtract y-axis origin of keyboard from device height, to come to correct value.
- (void)keyboardWillShow:(NSNotification *)notification
NSDictionary *info = [aNotification userInfo];
CGRect keyboardFrame = [info[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
keyboardFrame = [info[UIKeyboardFrameEndUserInfoKey] CGRectValue];
keyboardFrame = [self.view convertRect:keyboardFrame fromView:nil];
CGFloat yPosition = keyboardFrame.origin.y;
NSInteger height = [UIScreen mainScreen].bounds.size.height - yPosition;
}
Works for me on iOS9 with iPhones and iPads in both orientations.

- 3,340
- 3
- 29
- 37
I don't know what it is, but you could figure it out easily enough.
Surf on your iPad to a page with this...
JavaScript
var totalHeight = window.innerHeight;
document.getElementById('what-is-my-height').onclick = function() {
alert(totalHeight - window.innerHeight);
};
HTML
<button id="what-is-my-height">Bring up keyboard, then push me</button>
Click the button (after you have brought up the on screen keyboard), and it should tell you the height. Repeat for the other orientation.

- 479,566
- 201
- 878
- 984
-
I don't have an iPad and I don't have a web server, so this is not so easily done for me. I was hoping that someone could just provide the numbers. – Erik B Nov 18 '10 at 12:12
-
This is great on the ipad but doesn't seem to work on the iphone because it centers it. – Squirrl Jul 09 '14 at 06:21
-
This solution impossible in ios/safari. Because keyboard is not resizing main web view. – Erçin Dedeoğlu May 04 '20 at 10:34
I created this table which contains both the heights of iPhone and iPad keyboards, both for landscape and portrait mode, both with the toolbar on and off.
I even explained how you can use these dimensions in your code here.
Note that you should only use these dimensions if you need to know the keyboard's dimension before you layout the view. Otherwise the solutions from the other answers work better.

- 835
- 11
- 25