custom shortcut keyboard for Photoshop

Status
Not open for further replies.

musiquemeuble

Active member
Hello Guys,

I would like to create a custom shortcut keyboard for Photoshop with capacitive touch and a Teensy LC .

For exemple :

When I touch pin 0 > launch the shortcut 'Command + T'

Can you guys help me with the code ?

Thanks !
Florent
 
That's the one
For what you are after keeping things simple is the way to go, start with the examples, make sure you debounce your buttons properly and look at the keypad library if you are going beyond a single row of hotkeys and want more inputs without too much more complexity.

And be very careful of your project typing into your code and ruining it, especially if you are doing ctl+things - you do not want select all/delete/save to fire on anything important! Suggestion is to put a toggle switch of some form on your project, and only send keypresses when that switch is in the 'arm' position.
 
If you are using a button it is easy enough using examples like
https://learn.adafruit.com/adafruit-arduino-lesson-6-digital-inputs/overview
If you want this to be a capactivie sense/touch project you are looking at doing some filtering of your input to get repeatable results starting with
http://little-scale.blogspot.com/2017/05/teensy-36-basics-touchread.html

If the problem is how you actually send commands then you want to look at the keyboard examples in arduino->file->examples->teesny->usb keyboard - probably starting with buttons though you need to use ctl+key actions which will take a couple of iterations to get right.
 
It's working !

Code:
int touchRead_pin = 0; 
int data; 

int thresh = 2800; 
int play_flag = 0; 

int current; 

void setup() {

}

void loop() {
  current = touchRead(touchRead_pin); 

  if(current > thresh && play_flag == 0) {
    play_flag = 1;
     Keyboard.set_modifier(MODIFIERKEY_ALT | MODIFIERKEY_GUI); 
     Keyboard.send_now();
     Keyboard.press(KEY_W);
  }
  if(current < thresh && play_flag == 1) {
    play_flag = 0;
    Keyboard.set_modifier(0);
    Keyboard.set_key1(0);
    Keyboard.send_now(); 
    Keyboard.release(KEY_W); 
    delay(150);
  }
}
 
Status
Not open for further replies.
Back
Top