Advertisement

Time button is pressed

Started by January 07, 2016 06:13 PM
10 comments, last by Omar Bentaleb 8 years, 11 months ago

Hi guys do you know a way that i can calculate time while button is pressed on my keyboard

Its simple but if you want a code example you should specify what you're using. You just need a way to store time and to tell if the key is down or the key is up.


if(isButtonDown())
{
  clock.start();
 
}

if(isButtonUp())
{
  clock.stop();

}

Advertisement

You're going to have to provide more detail. Are you writing a program? If so, what language? Are you using any external libraries to handle input? Details, please.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

You're going to have to provide more detail. Are you writing a program? If so, what language? Are you using any external libraries to handle input? Details, please.

thank you for replying no i'm not writing any program i just want a way that i can calculate time button is pressed

Its simple but if you want a code example you should specify what you're using. You just need a way to store time and to tell if the key is down or the key is up.


if(isButtonDown())
{
  clock.start();
 
}

if(isButtonUp())
{
  clock.stop();

}

i just want a code that let me calculate time button is pressed on my computer keyboard

Its simple but if you want a code example you should specify what you're using. You just need a way to store time and to tell if the key is down or the key is up.


if(isButtonDown())
{
  clock.start();
 
}

if(isButtonUp())
{
  clock.stop();

}

i just want a code that let me calculate time button is pressed on my computer keyboard

But why do you want that?

There are a lot of ways to do it. Easy ways like using a library, and hard ways like writing everything yourself. We can't give you code without you specifying what language you're using or if you're using a library.

Advertisement

Just using Windows I assume? Sorry, I don't have any idea, outside of writing a program to do it for you.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

Just using Windows I assume? Sorry, I don't have any idea, outside of writing a program to do it for you.

can you please write me a program cause i don't know how and thank you

Its simple but if you want a code example you should specify what you're using. You just need a way to store time and to tell if the key is down or the key is up.


if(isButtonDown())
{
  clock.start();
 
}

if(isButtonUp())
{
  clock.stop();

}

i just want a code that let me calculate time button is pressed on my computer keyboard

But why do you want that?

There are a lot of ways to do it. Easy ways like using a library, and hard ways like writing everything yourself. We can't give you code without you specifying what language you're using or if you're using a library.

thank you for replying can you please tell me how to do it using library

Look into keyboard macro programs (or whatever theyre called) and keyloggers etc. Since they log the times of recorded events (which seems to be what you want).

Eg I found this with some googling, and in the picture near middle of that page it shows some events, with duration in milliseconds (I dont know, you have to record some keypresses, then open that edit window it shows??).

But I doubt anybody is going to write you a program - you didnt even say why you need it or give any sort of detail, and writing a program takes time. At least not for free.

edit:

If you want to write it yourself, youll need to know how to program (at least basics). If you do know how, or if you dont but are willing to dedicate lots of time to learn, then do say so.

o3o

This topic is closed to new replies.

Advertisement