Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
ccbEmulateKey - shift key emulation doesn't work with

okeoke
Registered User
Quote
2023-07-22 12:09:44

I'm trying to make ccbEmulateKey to work with a built-in "Object controlled by keyboard" behavior.
Every button work except shift key, which makes character run. It seems like emulation is still working and key event is actually triggered, but it doesn't seem to affect this specific behavior.

Demo is here:https://drive.google.com/file/d/...

G key turns on shift key emulation - this could be seen in the text output. It also trigger shift "key press" event same as pressing actual shift key on the keyboard,

Even though, everything seems to be setup properly, G key doesn't trigger sprint for the character.

Does anyone faced this before, did I set it up incorrectly, and if this is an actual issue is there any workaround?

I also tried different other approach, like making ccbEmulateKey spam shift with different intervals, use keycodes for left and right shift (160 and 161) - nothing seems to work.


Guest
Guest
Quote
2023-07-22 15:34:16

JIC, in his discord said that, he fixed the issue with shift and control key for Emulate key but it will be in next update of Coppercube, the current API automatically emulate "shift" key always, along with every other key.


okeoke
Registered User
Quote
2023-07-22 16:09:51

Thank you for the info. I guess, I'll have to come back to this in a couple of years than.


just_in_case
Moderator
Quote
2023-07-22 17:48:17

Yeah, the "shift" key bug was fixed but I think you wanted to eulate shift key with G right? Just in case you don't know Coppercube use some special keycodes for some keys instead of standard Javascript key code.


instead of "16" it uses "160" for left shift key and for right shift key it uses "161" as key code. Also for emulating mouse keys You can use 0,1,2 as keycodes.

hope this might be helpful to you, and you don't have to wait for next update.


okeoke
Registered User
Quote
2023-07-22 19:13:32

Thank you for the reply - "G" is only for this example. In a real code changed it based on a variable, it looks like:
    if (!this.isShiftCurrentlyPressed && Math.abs(ccbGetCopperCubeVariable(this.button_sprint)) > this.deadZone) {
ccbEmulateKey(KEY_L_SHIFT, true);
this.isShiftCurrentlyPressed = true;
} else if (this.isShiftCurrentlyPressed && Math.abs(ccbGetCopperCubeVariable(this.button_sprint)) < this.deadZone) {
ccbEmulateKey(KEY_L_SHIFT, false);
this.isShiftCurrentlyPressed = false;
}


I also tried both 160 and 161, and it doesn't work with bult-in behavior, even though, if I add an "if key pressed" behavior it's triggered by key emulation.
In fact I tried all keycodes from 0 to 255:) None of these trigger sprint for the built-in behavior.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internat?onal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact