if (Game.IsControlJustReleased(0, Control.Phone))
{
//My code here...
}
But I have to press 3 or 4 times the key before the code is executed. That is why I wanted to execute the code out of the tick function to make it more responsive…
You shouldn’t have to press it multiple times. It should work if you press it once – always. Do you have any await in your OnTick function? If so, that would cause this to not work every press.
You shouldn’t have any delays in the main Tick function. If you need to put any delays, but it inside any of the sub-tasks. Thats probably what is causing it, because it will be skipping a frame.
for avoid the warning , just put at the end of your OnTick task : await Task.FromResult(0);
ps : check closer in the Game class you have different function about the key for get a press key , and pressed key ect… very usefull depending what you want to do
Thank you @304bl. It works . I have also checked the different functions for keys. Some are very sensitive, press once and you get your code executed several times