Click Drag function. Need Help with this Script I get Syntax Errors.

tell application "System Events"

    set theF24Down to
false

    set theF23Down to
false

    set
startMouseCoordinate to {}

    on key down theKey

        if theKey is
"F24" then

            set
theF24Down to true

            set startMouseCoordinate
to get mouse location

            set
xCoordinate to (startMouseCoordinate's x)

            set
yCoordinate to (startMouseCoordinate's y)

            set
endTime to (current date) + (350 * milliseconds)

            mouse down
at {xCoordinate, yCoordinate}

            repeat

                set
mouseCoordinate to get mouse location

                if
mouseCoordinate is not {xCoordinate, yCoordinate} then

                   
set endTime to (current date) + (350 * milliseconds)

                    set xCoordinate to (mouseCoordinate's
x)

                   
set yCoordinate to (mouseCoordinate's y)

                end if

                if
(current date) > endTime then

                   
exit repeat

                end if

            end repeat

            mouse up
at {xCoordinate, yCoordinate}

            mouse move
{xCoordinate, yCoordinate + 10}

            set mouse
position to startMouseCoordinate

        else if theKey
is "F23" then

            set
theF23Down to true

            set
startMouseCoordinate to get mouse location

            set
xCoordinate to (startMouseCoordinate's x)

            set
yCoordinate to (startMouseCoordinate's y)

            set
endTime to (current date) + (350 * milliseconds)

            mouse down
at {xCoordinate, yCoordinate}

            repeat

                set
mouseCoordinate to get mouse location

                if
mouseCoordinate is not {xCoordinate, yCoordinate} then

                   
set endTime to (current date) + (350 * milliseconds)

                   
set xCoordinate to (mouseCoordinate's x)

                   
set yCoordinate to (mouseCoordinate's y)

                end if

                if
(current date) > endTime then

                   
exit repeat

                end if

            end repeat

            mouse up
at {xCoordinate, yCoordinate}

            mouse move
{xCoordinate, yCoordinate - 10}

            set mouse
position to startMouseCoordinate

        end if

    end key down

end tell

Hello I wanted to remap an F23/F24 keys to do an action when I press them. All I want is similar to a Click and Drag function.

You get errors from stuff like declaring a handler in a tell statement, missing handlers or applications that perform commands such as mouse up, mouse move, and get mouse location, bad syntax for several if statements, and just bad formatting in general.  This script has no chance of running - where did you get it or the commands you are trying to use? 

Click Drag function. Need Help with this Script I get Syntax Errors.
 
 
Q