≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
how to check key press once
Posted by:
(you are not logged in)
Enter the missing letter in: "Internation?l"
(you are not logged in)
Text:
[quote][b][/b] wrote: I misread the question.. in javascript i do it like this.. [code]/* <behavior jsname="behavior_IF_KEY_PRESSED" description="IF_KEY_PRESSED"> <property name="Keycode" type="int" default="13" /> <property name="Action" type="action"/> </behavior> */ key_p = [250]; for(var i=0; i<250; ++i) key_p.push(0); key_l = [250]; for(var i=0; i<250; ++i) key_l.push(0); ccbRegisterKeyDownEvent("keyPressedDown"); function keyPressedDown(keyCode) { key_p[keyCode]=1; //print("pressed key KEYCODE" +keyCode); } ccbRegisterKeyUpEvent("keyPressedUp"); function keyPressedUp(keyCode) { key_p[keyCode]=0; key_l[keyCode] =0; } behavior_IF_KEY_PRESSED = function() { }; behavior_IF_KEY_PRESSED.prototype.onAnimate = function() { if (key_p[this.Keycode] == 1 && key_l[this.Keycode] == 0) { key_l[this.Keycode] =1; ccbInvokeAction(this.Action); } return true; } [/code] If you want to use this script then you need keycode.. ENTER key is 13 so you can use it if key pressed 13 then call action.. and it will be called only once per click.[/quote]
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