Scripts for cursor arrows


#1

I would like to know whether it is possible to add to a keyboard row cursor arrow keys to up a line, down a line, forward a word, back a word, etc

I have no knowledge of the scripting language of Drafts 5 but looking at the provided script to one character forward:

// move cursor
var selRange = editor.getSelectedRange();
editor.setSelectedRange(selRange[0]+1, 0);

it does not appear obvious how to do what I would like to do.

Any help would be gratefully received.


#2

There are some cursor actions here: https://actions.getdrafts.com/g/1D0


#3

dchar,

Thank you for very much for the cursor actions link.

Are the action/scripts for going forward and back one word as well?


#4

I’ll add them and update


#5

I updated the action group with next / previous word. I tried to match the behavior of my text editor and how it handles jumping with newlines and punctuation which might be useful when editing JavaScript.

LMK if you have any issues.

https://actions.getdrafts.com/g/1D0


#6

dchar,

Thank you for creating tese.

The cursors for left a word and right a word exist in Drafts 4 - and it is possible to export actions from 4 to 5, but not for these two, unfortunately.


#7

Nice action, Does anyone have any script to move the cursor to either to beginning or end of the draft? Or to move the cursor up/down x number of lines? Thank you


#8

I’ll add beginning and end of draft to the action group. They’re easy.


#9

Thank you @dchar!! This is a big help.


#10

Added actions for beginning and end of draft.

Since keyboard space is limited I added two actions to

  • toggle between the beginning and end of line
  • toggle between the beginning and end of draft