mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 06:06:41 +01:00
Hacky way to show on-screen keyboard
Doesn't work some of the time.
This commit is contained in:
parent
311160983f
commit
d2af509eaf
2 changed files with 18 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
|
||||
import openCompose from '../utils/open-compose';
|
||||
import openOSK from '../utils/open-osk';
|
||||
import states from '../utils/states';
|
||||
|
||||
import Icon from './icon';
|
||||
|
@ -14,6 +15,7 @@ export default function ComposeButton() {
|
|||
states.showCompose = true;
|
||||
}
|
||||
} else {
|
||||
openOSK();
|
||||
states.showCompose = true;
|
||||
}
|
||||
}
|
||||
|
|
16
src/utils/open-osk.jsx
Normal file
16
src/utils/open-osk.jsx
Normal file
|
@ -0,0 +1,16 @@
|
|||
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); // https://stackoverflow.com/a/23522755
|
||||
|
||||
export default function openOSK() {
|
||||
if (isSafari) {
|
||||
const fauxEl = document.createElement('input');
|
||||
fauxEl.style.position = 'absolute';
|
||||
fauxEl.style.top = '0';
|
||||
fauxEl.style.left = '0';
|
||||
fauxEl.style.opacity = '0';
|
||||
document.body.appendChild(fauxEl);
|
||||
fauxEl.focus();
|
||||
setTimeout(() => {
|
||||
document.body.removeChild(fauxEl);
|
||||
}, 500);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue