Cc.TextFieldTTF not reading keyboard correctly on web application

Hi there,

First I want to thank you hugely for this port and the speed at which it is coming together. I have a project I am trying to deliver for next month that I had been building on a commercial HTML5 platform. Unfortunately there was so little in the stack that I was looking to have to build a whole framework. I am very glad for a cocos2D stack in JS as I have used cocos2D-iPhone in the past.

The issue I am currently having is with cc.TextFieldTTF. It currently is reading my Mac and PC/linux keyboards incorrectly. I am not familiar with this feature but really want to use it.

This is also occurring in the test suite under the TextInputTest available here (http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Html5).

All input is being forced to uppercase. Characters above the numbers are not usable (particularly @ … I am trying to request email addresses). Other non alpha-numerics don’t work correctly (i.e. / produces the upside down question mark).

I have tried this on several computers and Safari, Chrome and Firefox.

Please let me know if I am doing something wrong (am I supposed to set some keyboard setting? If so the test suite seems to have missed this as well) or perhaps point me to the code in the platform that I should investigate (I am digging in now).

Thanks again,
Alan

this feature has this bug. we get the keycode and use “String.fromCharCode(keyCode)” to convert to char. but the input is being forced to uppercase. we will fixed the but coming soon. thanks very much.

Thanks very much.

I’ll wait for the fix.

I have looked into the issue a little more.

The String.fromCharCode(keyCode) function is performing correctly. A keycode is being passed in when a charcode is needed.

This stems from use of the keydown event generating the call to processKeyCode in CCIMEDispatcher.js file.
A keypress event will generate the correct charCode (‘a’ is 97 …. ‘A’ is 65).

The eventlistener is set up in CCKeyboardDispatcher.js.

This works but there seems to be a problem with special characters not coming through on the keypress event (like the delete key). I’m not sure why this is happening because sites like http://www.w3.org/2002/09/tests/keys.html would indicate that a delete (keycode 8) comes through a keypress as well. Perhaps the canvas eventlistener is different than the DOM listener?

I am going to write some code to work around this oddity.