Q:

digispark - 2 pin push button to iterate through an hashmap

I'm trying to create a project with my digispark where i can iterate through an hashmap, when i press the push button the digispark writes via digikeyboard the values from an hashmap. Each time i press the button it's supposed to write the first value, then i press the push button again and in the same line it cleans what was written in the first value and writes the second value and so on. when the last value is reached it goes again to the first value if the button is pressed.
Right now i'm trying to put the iterator to work preperlly, this is the code i have:
#include "DigiKeyboard.h"
#include "HashMap.h"

HashMap<String, String> hashMap;
int i = 0;

void setup() {
   //setup hashmap
  hashMap.put("key0","test0");
  hashMap.put("key1","test1");
  hashMap.put("key2","test2");
  hashMap.put("key3","test3");
  hashMap.put("key4","test4");

  DigiKeyboard.sendKeyStroke(0);
  pinMode(0, INPUT);
}
void loop() {
  int sensorValue = digitalRead(0);
      while(sensorValue ==1 and i < hashMap.count())
      { 
        delay(100);
        DigiKeyboard.println( hashMap.valueAt(i));
        i++;
      } 
}

when i plug the digispark it prints automatically the first and the second value ("test0" "test1") and every time i press the button i get nothing.
This is my configuration:
http://cdn.instructables.com/FZA/0UN8/HI3TXV8D/FZA0UN8HI3TXV8D.LARGE.jpg
Can anyone help me please?

A:

thank you all.
i've manage to found a solution to my problem with this code, probably is not the most elegant way to do it but it works:
#include "DigiKeyboard.h"
#include "HashMap.h"

HashMap<char*, char*> hashMap;
int i = 0;
bool flag;

const byte switchPin = 0;
byte oldSwitchState = HIGH;  // assume switch open because of pull-up resistor
const unsigned long debounceTime = 100;  // milliseconds
unsigned long switchPressTime;  // when the switch last changed state

void setup ()
  {
  pinMode (switchPin, INPUT_PULLUP);

     //setup hashmap
  hashMap.put("key0","test0");
  hashMap.put("key1","test1");
  hashMap.put("key2","test2");
  hashMap.put("key3","test3");
  hashMap.put("key4","test4");

  DigiKeyboard.sendKeyStroke(0);

  }  // end of setup

void loop ()
  {
  // see if switch is open or closed
  byte switchState = digitalRead (switchPin);

  // has it changed since last time?
  if (switchState != oldSwitchState)
    {
    // debounce
    if (millis () - switchPressTime >= debounceTime)
       {
       switchPressTime = millis ();  // when we closed the switch 
       oldSwitchState =  switchState;  // remember for next time 
       if (switchState == HIGH)
          {
            delay(500);
            flag = true;
           while(i < hashMap.count() and flag == true)
            {  
              DigiKeyboard.println( hashMap.valueAt(i));
              i++;
              flag = false;
              }
          }  // end if switchState is LOW           
       }  // end if debounce time up

    }  // end of state change

  // other code here ...

  }  // end of loop

