Created
November 14, 2017 14:37
-
-
Save sainu/50e71dd3157d9890eb280d684159ce34 to your computer and use it in GitHub Desktop.
日本語入力が確定しているかどうかを判定するクラス
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* How to use in Vue | |
* export default { | |
* template: ` | |
* <input type="text" @keydown="imeChecker.keydownEvent" @keyup.enter="keyupEvent"> | |
* `, | |
* data() { | |
* return { | |
* imeChecker: new ImeChecker() | |
* } | |
* }, | |
* methods: { | |
* keyupEvent($event) { | |
* if (imeChecker.imeIsNotActive) { | |
* do something... | |
* } | |
* } | |
* } | |
* } | |
*/ | |
export default class ImeChecker { | |
constructor() { | |
this.imeFlag = false; | |
} | |
keydownEvent(e) { | |
this.imeFlag = e.keyCode == 229; | |
} | |
// 日本語入力が確定しているかどうか | |
// 確定している true | |
// 確定していない false | |
get imeIsNotActive() { | |
return !this.imeFlag; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment