Jump to content

HTML5 - Canvas Number Input

Hi, does anyone know how to get user input from a keylistener and input numbers on a canvas?

Is there a method of implementing a text cursor to signal where the text is going to be input and enter keys?

Also can you set text boundaries?

Here is my current code for letter input:

					window.addEventListener("keyup", keyUpHandler, true);					function addletter(letter) {						keyHistory += letter;						ctx.clearRect(0, 0, 300, 300);						ctx.fillText(keyHistory, 20, 20);					}					function keyUpHandler(event) {						var letters = "abcdefghijklmnopqrstuvwxyz";						var key = event.keyCode;						if (key > 64 && key < 91) {							var letter = letters.substring(key - 64, key - 65);							addletter(letter);						}					}

"Instinct or Rationality; Which will you choose? Enchanted by a superiority complex"

"what you do in spite of internet speed is inspiring. :3" From Cae - 2015

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×