user4527: I have a Teensy set up as a keyboard, joystick, and I'm giving keyboard commands. Letter and number keys are going fine. But when I try sending ENTER, I get some extra code in my Linux terminal:
$ 16424
16424: command not found

the code I have to give the ENTER key goes like this:
void setup() {
  pinMode(0, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
  Serial.begin(9600);
}

void loop() {
  // read the digital inputs and set the buttons
  Joystick.button(1, digitalRead(0));
  Serial.println(digitalRead(0));
  if(digitalRead(0)==0){
    Keyboard.println(KEY_ENTER);
  }
  delay(50);
}

where is this  "16424" coming from, and how do I send an ENTER keypress?
I am using a Teensy 2.0, on Linux, with Arduino IDE 1.6.7.

user4143: You can't just "print" a key like that. You use print for sending text.
When you use println it sends an enter key along with your text, so you can do :
Keyboard.println("ls -al");

and it will send the text ls -al and press enter for you.
If you want to do it in the 'raw' way you will need to press and then release the key:
Keyboard.press(KEY_ENTER);
Keyboard.release(KEY_ENTER);


4527: <p>I have a Teensy set up as a keyboard, joystick, and I'm giving keyboard commands. Letter and number keys are going fine. But when I try sending ENTER, I get some extra code in my Linux terminal:</p>

<pre class="lang-none prettyprint-override"><code>$ 16424
16424: command not found
</code></pre>

<p>the code I have to give the ENTER key goes like this:</p>

<pre class="lang-cpp prettyprint-override"><code>void setup() {
  pinMode(0, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
  Serial.begin(9600);
}

void loop() {
  // read the digital inputs and set the buttons
  Joystick.button(1, digitalRead(0));
  Serial.println(digitalRead(0));
  if(digitalRead(0)==0){
    Keyboard.println(KEY_ENTER);
  }
  delay(50);
}
</code></pre>

<p>where is this  "16424" coming from, and how do I send an ENTER keypress?
I am using a Teensy 2.0, on Linux, with Arduino IDE 1.6.7.</p>
 4143: <p>You can't just "print" a key like that. You use <code>print</code> for sending text.</p>

<p>When you use <code>println</code> it sends an enter key along with your text, so you can do :</p>

<pre><code>Keyboard.println("ls -al");
</code></pre>

<p>and it will send the text <code>ls -al</code> and press enter for you.</p>

<p>If you want to do it in the 'raw' way you will need to press and then release the key:</p>

<pre><code>Keyboard.press(KEY_ENTER);
Keyboard.release(KEY_ENTER);
</code></pre>
