You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
2.8 KiB

8 years ago
  1. Keyboard
  2. ======
  3. The `cordova.plugins.Keyboard` object provides functions to make interacting with the keyboard easier, and fires events to indicate that the keyboard will hide/show.
  4. cordova plugin add ionic-plugin-keyboard
  5. Methods
  6. -------
  7. - cordova.plugins.Keyboard.hideKeyboardAccessoryBar
  8. - cordova.plugins.Keyboard.close
  9. - cordova.plugins.Keyboard.disableScroll
  10. - cordova.plugins.Keyboard.show
  11. Properties
  12. --------
  13. - cordova.plugins.Keyboard.isVisible
  14. Events
  15. --------
  16. These events are fired on the window.
  17. - native.keyboardshow
  18. * A number `keyboardHeight` is given on the event object, which is the pixel height of the keyboard.
  19. - native.keyboardhide
  20. # API reference
  21. Keyboard.hideKeyboardAccessoryBar
  22. =================
  23. Hide the keyboard accessory bar with the next, previous and done buttons.
  24. cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
  25. cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
  26. Supported Platforms
  27. -------------------
  28. - iOS
  29. Keyboard.close
  30. =================
  31. Close the keyboard if it is open.
  32. cordova.plugins.Keyboard.close();
  33. Supported Platforms
  34. -------------------
  35. - iOS, Android, Blackberry 10, Windows
  36. Keyboard.disableScroll
  37. =================
  38. Prevent the native UIScrollView from moving when an input is focused. The telltale sign that this is happening is the top of your app scrolls out of view (if using Ionic, your header bar will disappear).
  39. This does *not* prevent any DOM elements from being able to scroll. That needs to happen from CSS and JavaScript, not this plugin.
  40. cordova.plugins.Keyboard.disableScroll(true);
  41. cordova.plugins.Keyboard.disableScroll(false);
  42. Supported Platforms
  43. -------------------
  44. - iOS, Windows
  45. Keyboard.show
  46. =================
  47. Force keyboard to be shown. This typically helps if autofocus on a text element does not pop up the keyboard automatically
  48. cordova.plugins.Keyboard.show();
  49. Supported Platforms
  50. - Android, Blackberry 10, Windows
  51. native.keyboardshow
  52. =================
  53. This event fires when the keyboard will be shown or when the keyboard frame resizes (when switching between keyboards for example)
  54. window.addEventListener('native.keyboardshow', keyboardShowHandler);
  55. function keyboardShowHandler(e){
  56. alert('Keyboard height is: ' + e.keyboardHeight);
  57. }
  58. Properties
  59. -----------
  60. keyboardHeight: the height of the keyboard in pixels
  61. Supported Platforms
  62. -------------------
  63. - iOS, Android, Blackberry 10, Windows
  64. native.keyboardhide
  65. =================
  66. This event fires when the keyboard will hide
  67. window.addEventListener('native.keyboardhide', keyboardHideHandler);
  68. function keyboardHideHandler(e){
  69. alert('Goodnight, sweet prince');
  70. }
  71. Properties
  72. -----------
  73. None
  74. Supported Platforms
  75. -------------------
  76. - iOS, Android, Blackberry 10, Windows