Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android keyboard support workaround code #119

Open
JohnnyFun opened this issue May 24, 2018 · 1 comment
Open

Android keyboard support workaround code #119

JohnnyFun opened this issue May 24, 2018 · 1 comment

Comments

@JohnnyFun
Copy link

JohnnyFun commented May 24, 2018

Hi!

I noticed chrome android was setting which and keyCode to 229 since it's a soft keyboard. It seems like a relatively new thing they started doing. Anywho, I ended up just writing the following to make backspace and comma work on my android phone:

handleNonStandardKeyboards() {
	const input = this.taggle.getInput()
	input.addEventListener('keyup', e => {
		const key = e.which || e.keyCode
		const normalKeyboard = key !== 229
		if (normalKeyboard) return
		value = input.value

		//back
		const removing = value.length === 0
		if (removing) {
			const values = this.taggle.tag.values
			this.taggle.remove(values[values.length - 1])
			return
		}

		//comma
		const endsWithComma = /,$/.test(value)
		if (endsWithComma) {
			const tag = value.replace(',', '')
			this.taggle.add(tag)
			input.value = ''
			return
		}
	})
}

I haven't done extensive testing, but hope that helps anyone who runs into the same issue or someone who is more ambitious and willing to write a well-tested pull request.

@okcoker
Copy link
Owner

okcoker commented May 24, 2018

So keyCode has been deprecated and when the next major version of this is released i'll drop support for ie 8/9 in which case I'll probably switch to e.key as mentioned in #67 a while ago. Testing on my android, there's still some things that need to be looked into (The input gets repopulated with the last tag text) but I've started experimenting here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants