media.onSoftKeyEvent - GiGAGenie-ServiceSDK/UserGuide GitHub Wiki
gigagenie.media.onSoftKeyEvent
API 설명
- 한글 소프트 키 이벤트 수신 API
- KeyEvent를 발생시키지 않는 한글 소프트 키 이벤트를 수신함
- 영어 입력은 eventListener를 사용해 수신
- showSoftKeyboard API 참고
API 구조
- function callback(extra)
extra
composing
: (Int) 조합중인 자음 모음 개수
key
: (String) 입력된 한글
사용 예시
// callback 방식
const backKeyeventCallback = function(event) {
console.log(event)
switch(event.keyCode) {
case 8:
var value = this.document.querySelector('input').value;
this.document.querySelector('input').value = value.slice(0, -1);
break;
}
}
var inputData = "";//이전에 입력된 데이터
gigagenie.media.onSoftKeyEvent = function (extra) {
window.addEventListener("keydown", backKeyEventCallback);
var value = document.querySelector('input').value;//변경될 text element
if(extra.composing!=1) {
if(inputData.length>0) value = value.slice(0, -inputData.length); //마지막에 입력된 데이터만 받기
}
document.querySelector('input').value = value + extra.key;
inputData = extra.key;
};