Hi everyone,
I can't seem to get the MultiKey template to print a key out instead of outputting a serial. Can anyone help me rework the code so that it'll allow for this? I had a look through the H file and the Keypad doesn't seem to allow for this while using millis for multiple key presses.
I think I've just confused myself to be honest, I'm very new to arduino and would appreciate any help anyone's willing to lend.

Thankyou in advance!
I've attached the template in a .txt file, but it's accessible from the arduino program
Multikey.txt (1.77 KB)
You should have posted the code, (in [code]code tags[/code]
), rather than attaching it.
Here it is:-
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] =
{
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the kpd
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
unsigned long loopCount;
unsigned long startTime;
String msg;
void setup()
{
Serial.begin(9600);
loopCount = 0;
startTime = millis();
msg = "";
}
void loop()
{
loopCount++;
if ( (millis() - startTime) > 5000 )
{
Serial.print("Average loops per second = ");
Serial.println(loopCount / 5);
startTime = millis();
loopCount = 0;
}
// Fills kpd.key[ ] array with up-to 10 active keys.
// Returns true if there are ANY active keys.
if (kpd.getKeys())
{
for (int i = 0; i < LIST_MAX; i++) // Scan the whole key list.
{
if ( kpd.key[i].stateChanged ) // Only find keys that have changed state.
{
switch (kpd.key[i].kstate) // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
{
case PRESSED:
msg = " PRESSED.";
break;
case HOLD:
msg = " HOLD.";
break;
case RELEASED:
msg = " RELEASED.";
break;
case IDLE:
msg = " IDLE.";
}
Serial.print("Key ");
Serial.print(kpd.key[i].kchar);
Serial.println(msg);
}
}
}
} // End loop
Edit: I don't understand what you mean by this:-
I can't seem to get the MultiKey template to print a key out instead of outputting a serial.
Could you please rephrase it and explain a little better? Doesn't it already print the keys (that have changed state)?
Edit2:
.....while using millis for multiple key presses.
In this code, 'millis()' has nothing to do with the keypress stuff. It only times the 'loop()' function and prints out how many times the 'loop()' function cycles per second. Totally unrelated to the key presses.
Hi Steve,
Thanks for taking the time to help, I'll be sure to use the correct format for asking questions next time 
What I mean is, is that the multikey template only shows what button's been pressed in serial monitor. I need it to show what has been pressed like a keyboard would, so that it'll show up in a text document.
I've tried changing the 'Serial.print("key ")' function to 'Keyboard.press(key)' which worked in another sketch I've been working on, but it threw a bunch of errors at me.
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] =
{
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};
byte rowPins[ROWS] = {13, 12, 11, 10}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {A0, A1, A2}; //connect to the column pinouts of the kpd
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
unsigned long loopCount;
unsigned long startTime;
String msg;
void setup()
{
  Serial.begin(9600);
  loopCount = 0;
  startTime = millis();
  msg = "";
}
void loop()
{
  loopCount++;
  if ( (millis() - startTime) > 5000 )
  {
    Serial.print("Average loops per second = ");
    Serial.println(loopCount / 5);
    startTime = millis();
    loopCount = 0;
  }
  // Fills kpd.key[ ] array with up-to 10 active keys.
  // Returns true if there are ANY active keys.
  if (kpd.getKeys())
  {
    for (int i = 0; i < LIST_MAX; i++) // Scan the whole key list.
    {
      if ( kpd.key[i].stateChanged ) // Only find keys that have changed state.
      {
        switch (kpd.key[i].kstate)  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
        {
          case PRESSED:
            msg = " PRESSED.";
            break;
          case HOLD:
            msg = " HOLD.";
            break;
          case RELEASED:
            msg = " RELEASED.";
            break;
          case IDLE:
            msg = " IDLE.";
        }
        Keyboard.press("Key ");
        Serial.print(kpd.key[i].kchar);
        Serial.println(msg);
      }
    }
  }
}Â // End loop
As you can tell I'm still pretty new to Arduino, so I really appreciate the help 
timmeh12:
Hi Steve,
Thanks for taking the time to help, I'll be sure to use the correct format for asking questions next time 
What I mean is, is that the multikey template only shows what button's been pressed in serial monitor. I need it to show what has been pressed like a keyboard would, so that it'll show up in a text document.
I've tried changing the 'Serial.print("key ")' function to 'Keyboard.press(key)' which worked in another sketch I've been working on, but it threw a bunch of errors at me.
As you can tell I'm still pretty new to Arduino, so I really appreciate the help 
Ah, now I get what you want. I'm afraid that with most Arduino boards that's not possible. They only send serial comms and don't emulate keyboards, mice etc.
You didn't mention which Arduino board you have, so I'm assuming an UNO, Pro Mini, Mega2560 or similar.
Having said that, some boards can do it. The ones with a native USB port, like the Due. With those boards, you can include a "Keyboard" library, then send keyboard key presses to the computer.
On the UNO etc, the only way to do it would be to send serial, then have a program running on the computer that accepts serial input then generates keyboard key presses. I did a similar thing recently to send "hot key" presses to the VLC media player, but I had to write the Windows program myself.
I see this tread and TS take up some problem whit use Arduino.
I after several hour´s googling and find this Use Serial.print() to display Arduino output on your computer monitor: Part 2 - Programming Electronics Academy i get finally how Arduino works and what TS have for issue.
And sadly is locks like I can´t program a keyboard properly (I has a plan to use Numpad and Microcontroller)? Is not so common code made for ARM and what i find is not easy to change (to my needs).
I can some code (make some coding in autohotkey).
I not certain if i should make new tread or if TS find a solution hi not post.