Tuesday, November 5, 2024
spot_img

Multilanguage Help For Keyboard inputs? – Cocos Creator


Hello,

contemplating following code, the way it’s attainable to get precise character kind as an alternative of it’s code, no matter keyboard language it at all times provides identical key press code

enter.on(Enter.EventType.KEY_DOWN, (occasion: EventKeyboard)=>{
     console.log("occasion.keyCode: ", occasion.keyCode); //65 on keyA press 
}, this);

however following code works as per the keyboard language character typed and returns the precise character typed

doc.addEventListener('keydown', perform(occasion) {
    console.log('occasion.key:', occasion.key);
]});

tips on how to entry .key property or just like entry the precise character typed reasonably getting keyCodes which doesn’t even help multilanguage as typing ф returns 65 code and typing ‘a’ additionally returns 65 code in first code pattern

I attempted however the concern is a sure key press at all times return the identical keyCode no matter it’s language, so let’s say if I press ‘a’ then it returns keycode 65, if I swap the language to Russian and now urgent ‘a’ key suppose to generate apart from 65 keyCode which interprets to image ‘ф’ utilizing String.fromCharCode to get precise typed letter.

However the concern is it doesn’t generate totally different keycode for identical key no matter language kind

As could be seen within the video the usual keyboard occasion of browser has .key property which holds precise char typed, however cocos on prime of it make it’s personal EventKeyboard and get solely the .code property from native occasion and fires.
I feel in earlier variations it was attainable however not in 3.8

Have any answer, anybody?

What’s the explanation for deprecating the native entry since v3.3?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles