hello I just started playingcanvas.
While designing multiplayer, I ran into an error in the chat-related function that the enter key was input on the PC but not on the mobile.
GamePlayManagerScript.prototype.update = function(e) {
if(this.gameStarted === true)
{
if (this.app.keyboard.wasPressed(pc.KEY_ENTER))
// if (this.app.keyboard.wasPressed(e.keycode === 13))
{
console.log("key : enter!");
alert("input enter");
// console.log(this.inputBoxChatMsgComp.script.input.checkFocus());
if(this.inputBoxChatMsgComp.script.input.isFocued() === true)
{
var textBoxVal = this.inputBoxChatMsgComp.script.input.getCleanValue();
this.lastMsg = textBoxVal;
this.inputBoxChatMsgComp.script.input.deleteValue();
this.inputBoxChatMsgComp.script.input.blur();
if(this.lastMsg !== "")
{
this.networkEntity.script.network.sendMsg(this.nicknameVal,this.lastMsg);
}
}
else
{
this.inputBoxChatMsgComp.script.input.focus();
}
// console.log("this.lastMsg = ", this.lastMsg);
}
if(this.inputBoxChatMsgComp.script.input.isFocued() === true)
{
this.allowMovement = false;
}
else
{
this.allowMovement = true;
}
}
};
pc.KEY_ENTER and e.keyCode === 13 Both do not work, is there a problem with the script?
If not, thanks for letting me know what the problem is.