Skip to content

Commit 2cd4156

Browse files
author
Krzysztof Kawalec
committed
Adding support for the state show in hardware keyboard for WP8.
1 parent d3c8a1b commit 2cd4156

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

js/utils/keyboard.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ function keyboardInit() {
9595

9696
document.body.addEventListener('orientationchange', keyboardOrientationChange);
9797

98-
document.removeEventListener('touchstart', keyboardInit);
98+
if (window.navigator.msPointerEnabled) {
99+
document.removeEventListener("MSPointerDown", keyboardInit);
100+
}
101+
else {
102+
document.removeEventListener('touchstart', keyboardInit);
103+
}
99104
}
100105

101106
function keyboardNativeShow(e) {
@@ -176,7 +181,12 @@ function keyboardShow(element, elementTop, elementBottom, viewportHeight, keyboa
176181
// any showing part of the document that isn't within the scroll the user
177182
// could touchmove and cause some ugly changes to the app, so disable
178183
// any touchmove events while the keyboard is open using e.preventDefault()
179-
document.addEventListener('touchmove', keyboardPreventDefault, false);
184+
if (window.navigator.msPointerEnabled) {
185+
document.addEventListener("MSPointerMove", keyboardPreventDefault, false);
186+
}
187+
else {
188+
document.addEventListener('touchmove', keyboardPreventDefault, false);
189+
}
180190

181191
return details;
182192
}
@@ -200,7 +210,12 @@ function keyboardHide() {
200210
});
201211

202212
// the keyboard is gone now, remove the touchmove that disables native scroll
203-
document.removeEventListener('touchmove', keyboardPreventDefault);
213+
if (window.navigator.msPointerEnabled) {
214+
document.removeEventListener("MSPointerMove", keyboardPreventDefault);
215+
}
216+
else {
217+
document.removeEventListener('touchmove', keyboardPreventDefault);
218+
}
204219
document.removeEventListener('keydown', keyboardOnKeyDown);
205220
}
206221

@@ -316,6 +331,11 @@ ionic.Platform.ready(function() {
316331

317332
// only initialize the adjustments for the virtual keyboard
318333
// if a touchstart event happens
319-
document.addEventListener('touchstart', keyboardInit, false);
334+
if (window.navigator.msPointerEnabled) {
335+
document.addEventListener("MSPointerDown", keyboardInit, false);
336+
}
337+
else {
338+
document.addEventListener('touchstart', keyboardInit, false);
339+
}
320340
});
321341

0 commit comments

Comments
 (0)