25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

README.md 7.7 KiB

4 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. # cordova-plugin-keyboard
  2. > This plugin provides the `Keyboard` object which has some functions to customize and control the keyboard. It also supports the __HideKeyboardFormAccessoryBar__ (boolean) and __KeyboardShrinksView__ (boolean) preferences in config.xml.
  3. This plugin has only been tested in Cordova 3.2 or greater, and its use in previous Cordova versions is not recommended (potential conflict with keyboard customization code present in the core in previous Cordova versions).
  4. If you do use this plugin in an older Cordova version (again, not recommended), you have to make sure the HideKeyboardFormAccessoryBar and KeyboardShrinksView preference values are *always* false, and only use the API functions to turn things on/off.
  5. This plugin was based on this Apache [project](https://github.com/apache/cordova-plugins/tree/master/keyboard) and has a compatible API.
  6. - [Installation](#installation)
  7. - [Methods](#methods)
  8. - [Keyboard.shrinkView](#keyboardshrinkview)
  9. - [Keyboard.hideFormAccessoryBar](#keyboardhideformaccessorybar)
  10. - [Keyboard.disableScrollingInShrinkView](#keyboarddisablescrollinginshrinkview)
  11. - [Keyboard.hide](#keyboardhide)
  12. - [Keyboard.show](#keyboardshow)
  13. - [Properties](#properties)
  14. - [Keyboard.isVisible](#keyboardisvisible)
  15. - [Keyboard.automaticScrollToTopOnHiding](#keyboardautomaticscrolltotoponhiding)
  16. - [Events](#events)
  17. - [keyboardDidShow](#keyboarddidshow)
  18. - [keyboardDidHide](#keyboarddidhide)
  19. - [keyboardWillShow](#keyboardwillshow)
  20. - [keyboardWillHide](#keyboardwillhide)
  21. - [keyboardHeightWillChange](#keyboardheightwillchange)
  22. - [Releases](#releases)
  23. # Installation
  24. From [npm](https://www.npmjs.com/package/cordova-plugin-keyboard) (stable)
  25. `cordova plugin add cordova-plugin-keyboard`
  26. From github latest (may not be stable)
  27. `cordova plugin add https://github.com/cjpearson/cordova-plugin-keyboard`
  28. # Methods
  29. ## Keyboard.shrinkView
  30. Shrink the WebView when the keyboard comes up.
  31. Keyboard.shrinkView(value, successCallback);
  32. #### Description
  33. Set to true to shrink the WebView when the keyboard comes up. The WebView shrinks instead of the viewport shrinking and the page scrollable. This applies to apps that position their elements relative to the bottom of the WebView. This is the default behaviour on Android, and makes a lot of sense when building apps as opposed to webpages.
  34. #### Supported Platforms
  35. - iOS
  36. #### Quick Example
  37. Keyboard.shrinkView(true);
  38. Keyboard.shrinkView(false);
  39. Keyboard.shrinkView(null, function (currentValue) { console.log(currentValue); });
  40. ## Keyboard.hideFormAccessoryBar
  41. Hide the keyboard toolbar.
  42. Keyboard.hideFormAccessoryBar(value, successCallback);
  43. #### Description
  44. Set to true to hide the additional toolbar that is on top of the keyboard. This toolbar features the Prev, Next, and Done buttons.
  45. #### Supported Platforms
  46. - iOS
  47. #### Quick Example
  48. Keyboard.hideFormAccessoryBar(true);
  49. Keyboard.hideFormAccessoryBar(false);
  50. Keyboard.hideFormAccessoryBar(null, function (currentValue) { console.log(currentValue); });
  51. ## Keyboard.disableScrollingInShrinkView
  52. Disable scrolling when the the WebView is shrunk.
  53. Keyboard.disableScrollingInShrinkView(value, successCallback);
  54. #### Description
  55. Set to true to disable scrolling when the WebView is shrunk.
  56. #### Supported Platforms
  57. - iOS
  58. #### Quick Example
  59. Keyboard.disableScrollingInShrinkView(true);
  60. Keyboard.disableScrollingInShrinkView(false);
  61. Keyboard.disableScrollingInShrinkView(null, function (currentValue) { console.log(currentValue); });
  62. ## Keyboard.hide
  63. Hide the keyboard
  64. Keyboard.hide();
  65. #### Description
  66. Call this method to hide the keyboard
  67. #### Supported Platforms
  68. - iOS
  69. - Android
  70. #### Quick Example
  71. Keyboard.hide();
  72. ## Keyboard.show
  73. Show the keyboard
  74. Keyboard.show();
  75. #### Description
  76. Call this method to show the keyboard.
  77. #### Supported Platforms
  78. - Android
  79. #### Quick Example
  80. Keyboard.show();
  81. # Properties
  82. ## Keyboard.isVisible
  83. Determine if the keyboard is visible.
  84. if (Keyboard.isVisible) {
  85. // do something
  86. }
  87. #### Description
  88. Read this property to determine if the keyboard is visible.
  89. #### Supported Platforms
  90. - iOS
  91. ## Keyboard.automaticScrollToTopOnHiding
  92. Specifies whenether content of page would be automatically scrolled to the top of the page
  93. when keyboard is hiding.
  94. Keyboard.automaticScrollToTopOnHiding = true;
  95. #### Description
  96. Set this to true if you need that page scroll to beginning when keyboard is hiding.
  97. This is allows to fix issue with elements declared with position: fixed,
  98. after keyboard is hiding.
  99. #### Supported Platforms
  100. - iOS
  101. # Events
  102. ## keyboardDidShow
  103. This event is fired when keyboard fully shown.
  104. window.addEventListener('keyboardDidShow', function () {
  105. // Describe your logic which will be run each time keyboard is shown.
  106. });
  107. #### Description
  108. Attach handler to this event to be able to receive notification when keyboard is shown.
  109. #### Supported Platforms
  110. - iOS
  111. ## keyboardDidHide
  112. This event is fired when the keyboard is fully closed.
  113. window.addEventListener('keyboardDidHide', function () {
  114. // Describe your logic which will be run each time keyboard is closed.
  115. });
  116. #### Description
  117. Attach handler to this event to be able to receive notification when keyboard is closed.
  118. #### Supported Platforms
  119. - iOS
  120. ## keyboardWillShow
  121. This event fires before keyboard will be shown.
  122. window.addEventListener('keyboardWillShow', function () {
  123. // Describe your logic which will be run each time when keyboard is about to be shown.
  124. });
  125. #### Description
  126. Attach handler to this event to be able to receive notification when keyboard is about to be shown on the screen.
  127. #### Supported Platforms
  128. - iOS
  129. ## keyboardWillHide
  130. This event is fired when the keyboard is fully closed.
  131. window.addEventListener('keyboardWillHide', function () {
  132. // Describe your logic which will be run each time when keyboard is about to be closed.
  133. });
  134. #### Description
  135. Attach handler to this event to be able to receive notification when keyboard is about to be closed.
  136. #### Supported Platforms
  137. - iOS
  138. ## keyboardHeightWillChange
  139. This event is fired when the keyboard is fully closed.
  140. window.addEventListener('keyboardHeightWillChange', function (event) {
  141. // Describe your logic which will be run each time when keyboard is about to be closed.
  142. console.log(event.keyboardHeight);
  143. });
  144. #### Description
  145. Attach handler to this event to be able to receive notification when keyboard is about to be closed.
  146. #### Supported Platforms
  147. - iOS
  148. # Releases
  149. - 1.0.0
  150. - Initial NPM release
  151. - Fix issues with external keyboards
  152. - Support keyboard events on window
  153. - Fix issues with split and undocked keyboards
  154. - Add keyboardHeightWillChange event
  155. - Fix issues with StatusBarOverlaysWebview
  156. - 1.1.0
  157. - Add hide/show for Android
  158. - Support original keyboard event mechanism
  159. - 1.1.1
  160. - Make compatible with cordova-android 3 and 4 (See [#2](/../../issues/2))
  161. - Add hide for iOS
  162. - 1.1.2
  163. - Fix issues with hiding the accessory bar (See [#3](/../../issues/3))
  164. - 1.1.3
  165. - Support hiding the accessory bar when using WKWebView as the engine (See [here](https://github.com/Telerik-Verified-Plugins/WKWebView/issues/85))
  166. - 1.1.4
  167. - Fix page scrolling (See [#14](/../../issues/14))
  168. - Prevent possible app store rejections (See [#21](/../../issues/21))
  169. - 1.1.5
  170. - Fix window.innerHeight when using WKWebView (See [#32](/../../issues/32))
  171. - 1.2.0
  172. - Return current values of shrinkView, disableScroll and hideFormAccessoryBar in a success callback
  173. - Fix scroller resizing bug (See [#55](/../../issues/55))
  174. - Fix iOS 11.1.1 WKWebView ShrinksView bug (See [#64](/../../issues/64))