ps2 keyboard question

i have a ps/2 keyboard hooked up my arduino and it is working great but i want it to do something after no key is pressed for 1 min, how would i go about that?

maintain a variable that tracks the value of millis ( ) each time a keystroke is pressed (maybe call it lastKeyTime). In your loop, check to see if the current value of millis ( ) minus the remembered value is larger than your desired inactivity time (60000).

ya thats what i thought i would do but and this is going to sound like a newbie question(because I'm a noob) but i don't really know how to do that.

// declare the lastKeyTime variable in the globals (before setup)
...
long lastKeyTime;
const int idleTime=60000;

void setup ( ) {
...
}

loop ( ) {
// somewhere in your code just after receiving a keypress
lastKeyTime = millis ( );
...
// somewhere else in the code, in a place that isn't conditional on processing a keypress
if ( millis ( ) - lastKeyTime > idleTime ) DoThatThingYouWantedToDoAfterAMinuteOfIdleTime ( );

Something like that... :wink:

so ya i got tat but what i need to know is how to tell if a key is pressed with out checking every byte. sorry about not being clear
I don't know if this helps any but this is my code :

#include <PS2Keyboard.h>  
#define KBD_CLK_PIN  3  
#define KBD_DATA_PIN 4
#define CHAR_ESC "\x1B"
#define CHAR_BS "\x08"
#define CHAR_LF "\x0A"
#define CHAR_CR "\x0D"
int r = 2;
int y = 7;
PS2Keyboard keyboard;  
  
void setup() {  
  pinMode(y, OUTPUT);
  pinMode(r, OUTPUT);
  Serial.begin(57600);
  
  Serial.print(CHAR_ESC "v");
  Serial.print("C.O.S.");
  Serial.print(CHAR_LF);
  Serial.print(CHAR_LF);  
  Serial.print(CHAR_CR);
  Serial.print("version 1.1.0    BETA 2.1.0");
  Serial.print(CHAR_LF);
  Serial.print(CHAR_LF);
  Serial.print(CHAR_CR);
  Serial.print("KEYBOARD AND T.V. USE");
  Serial.print(CHAR_ESC "x5");
  digitalWrite(r, HIGH);
  delay(10000);
  digitalWrite(r, LOW); 
  Serial.print(CHAR_ESC "y5");
  Serial.print(CHAR_ESC "E");
  keyboard.begin(KBD_DATA_PIN);  
  
  
}  
  
#define is_printable(c) (!(c&0x80))   // don't print if top bit is set  
  
void loop() {  
  
  if(keyboard.available()) {  
  
    // reading the "extra" bits is optional  
    byte   extra = keyboard.read_extra(); // must read extra before reading the character byte  
    byte       c = keyboard.read();  
  
    boolean ctrl = extra & 1;  // <ctrl> is bit 0  
    boolean  alt = extra & 2;  //  <alt> is bit 1  
  
    if (ctrl) Serial.print('^');  
    if (alt)  Serial.print('_');  
  
    if      (c==PS2_KC_UP)      Serial.print(CHAR_ESC "A");  
    else if (c==PS2_KC_DOWN)    Serial.print(CHAR_ESC "B");  
    else if (c==PS2_KC_RIGHT)   Serial.print(CHAR_ESC "C");
    else if (c==PS2_KC_LEFT)    Serial.print(CHAR_ESC "D");    
    else if (c==PS2_KC_DEL)     Serial.print(CHAR_ESC "E");  
    else if (c==PS2_KC_BKSP) {
     Serial.print(CHAR_BS); 
     Serial.print(" ");
     Serial.print(CHAR_BS);
    }
    else if (c==PS2_KC_PGUP) {
      Serial.print(CHAR_ESC "y:");
      digitalWrite(y, LOW);
    }  
    else if (c==PS2_KC_PGDN) {
      Serial.print(CHAR_ESC "x:"); 
      digitalWrite(y, HIGH); 
    }     
    else if (c==PS2_KC_ESC)     Serial.print(CHAR_ESC "Q");  
    else if ( is_printable(c) ) Serial.print(c);   // don't print any untrapped special characters  
  }   
}

what i need to know is how to tell if a key is pressed with out checking every byte.

Not sure what you mean by "checking every byte", but keyboard.available() is already telling you whether or not a key was pressed.

the keyboard sends out what i think is a hex code for every key pressed but it takes up to much room in my code to do that.

but it takes up to much room in my code to do that.

To do what?

There's a difference between checking "if a key is pressed" and checking "what key is pressed". Which are you trying to do? Why did you connect the ps2 keyboard, anyway?