         }
     }
     
+    static func keyGapPortrait(width: CGFloat, rowCharacterCount: Int) -> CGFloat {
+        let compressed = (rowCharacterCount >= self.keyCompressedThreshhold)
+        if compressed {
+            if width >= self.keyGapPortraitUncompressThreshhold {
+                return self.keyGapPortraitNormal
+            }
+            else {
+                return self.keyGapPortraitSmall
+            }
+        }
+        else {
+            return self.keyGapPortraitNormal
+        }
+    }
+    static func keyGapLandscape(width: CGFloat, rowCharacterCount: Int) -> CGFloat {
+        let compressed = (rowCharacterCount >= self.keyCompressedThreshhold)
+        let shrunk = self.keyboardIsShrunk(width)
+        if compressed || shrunk {
+            return self.keyGapLandscapeSmall
+        }
+        else {
+            return self.keyGapLandscapeNormal
+        }
+    }
+    
+    static func keyboardIsShrunk(width: CGFloat) -> Bool {
+        return width >= self.keyboardShrunkSizeBaseWidthThreshhold
+    }
     static func keyboardShrunkSize(width: CGFloat) -> CGFloat {
         if width >= self.keyboardShrunkSizeBaseWidthThreshhold {
             return self.findThreshhold(self.keyboardShrunkSizeArray, threshholds: self.keyboardShrunkSizeWidthThreshholds, measurement: width)

            let rowGapTotal = CGFloat(numRows - 1 - 1) * rowGap + lastRowGap
            
            // measurement
            let keyGaps: CGFloat = {
                let pastThreshhold = (CGFloat(mostKeysInRow) >= layoutConstants.keyGapsSmallThreshhold)
                return (pastThreshhold ? layoutConstants.keyGapsSmall : layoutConstants.keyGaps)
            }()
            
            // measurement
            let keyHeight: CGFloat = {

            
            // measurement
            let letterKeyWidth: CGFloat = {
                let totalGaps = (sideEdges * CGFloat(2)) + (keyGap * CGFloat(mostKeysInRow - 1))
                return (bounds.width - totalGaps) / CGFloat(mostKeysInRow)
            }()
            
            for (r, row) in enumerate(page.rows) {
                let rowGapCurrentTotal = (r == page.rows.count - 1 ? rowGapTotal : CGFloat(r) * rowGap)
                let frame = CGRectMake(sideEdges, topEdge + (CGFloat(r) * keyHeight) + rowGapCurrentTotal, bounds.width - CGFloat(2) * sideEdges, keyHeight)
                self.handleRow(row, keyGaps: keyGap, letterKeyWidth: letterKeyWidth, frame: frame)
            }
        }
    }
