How do I set this property?
Current behavior
Just now you have one operation:

apply an impulse (a force with the duration of one frame)

As you apply this impulse at subsequent frames again and again you get a constant force.
Be aware the value you describe as &quot;speed&quot; is no speed at all. It is the z-component of the force/impulse.
Request
You want changeable z-component of the force. This means you need new operations that change this strength.
Solutions
Additional forces
As you can add forces, you can simply add another force when shift is pressed.
if up:
    obj.applyForce((0, 0, zStrength), True)
    if shift:
        obj.applyForce((0, 0, additonalShiftZStrength), True)

Replace force
You calculate a different force to be applied:
if up and not shift:
    obj.applyForce((0, 0, zStrength), True)
if up and shift:
    obj.applyForce((0, 0, shiftZStrength), True)


Toggle

With this code I have to hold shift to change speed. But I want to change the speed at one click so that it will keep using the new speed when I press my uparrowkey.

In this case I suggest a different design at the higher abstraction level.
Lets see:

you want to use up to move forward
you want to use shift to switch to turbo strength
you want to use shift to switch to normal strength

State machine
I suggest to use states:

normal
turbo

Hint: Think about what a key press really means -&gt; what is the purpose of the key press. The design will be determined by the purpose rather than the key. Therefore I will not talk about up and shift anymore but &quot;move&quot; and &quot;toggle turbo&quot;. The easiest way to think about that is: how would you explain to a player what the keyboard key is used for.
You transit between the states this way:

when in normal state and &quot;toggle turbo&quot; is requested -&gt; transit to turbo

when in turbo state and &quot;toggle turbo&quot; is requested -&gt; transit to normal


This is our high-level behavior. You can switch state by requesting &quot;toggle turbo&quot; (pressing shift once).
Now the low-level behavior. With the two states we have two different low level behaviors:

when in normal state:
**when requesting to &quot;move&quot; -&gt; move with normal strength

when in turbo state:
**when requesting to &quot;move&quot; -&gt; move with turbo strength


The details are quite similar. The difference is the strength.
There are several options to implement a state machine. They mostly differ where to hold the state.
Build In states
Transitions:


And then add Actions:

Please note the [Level] switch is enabled. This ensures the sensor triggers the controller on state change and therefore activates the actuator without the need to release and press the button again.

The actuators are labeled: &quot;normal move&quot; and &quot;turbo move&quot;
Property
You store the mode in a property as you have just two of them you can use a boolean property.

To toggle the value you can use property actuators:

Then perform the according operations dependent on input and property value:

Dynamic strength
This more flexible than a state machine as you are not limited to a low number of states. But this solution is not that flexible in terms of difference between normal and turbo mode. The differences you can have is the force you apply.
The idea is that you use the current strength as &quot;state&quot;.

When you request &quot;toggle state&quot; and the current strength is high -&gt; reduce the strength.
When you request &quot;toggle state&quot; and the current strength is low -&gt; raise the strength.

These are still two operations:

toggle strength -&gt; which needs Python due to it's dynamic nature

move -&gt; which can be Logic bricks or Python


Both operations rely close together do to the shared strength.
The implementations differ in the way where you store the strength.
Motion actuator as storage
You can benefit from the fact that the motion actuator can store parameters. You simply re-configure the actuator when toggling turbo.
toggle_strength.py
import bge

controller = bge.logic.getCurrentController()

STRENGTH_NORMAL = 1
STRENGTH_TURBO = 10

if controller.sensors[0].positive:
    motionActuator = controller.actuators[&quot;move&quot;]
    force = motionActuator.force
    strength = force[2]
    
    newStrength = STRENGTH_TURBO if strength &lt; STRENGTH_TURBO else STRENGTH_NORMAL
    force[2] = newStrength
    motionActuator.force = force


Property as storage
A pure python solution requires you to store the current strength somewhere else. A good place would be the object itself -&gt; means a property.
toggle_strength.py
import bge

controller = bge.logic.getCurrentController()

INTERNAL_PROPERTY_STRENGTH = &quot;internal.strength&quot;

STRENGTH_NORMAL = 1
STRENGTH_TURBO = 10

if controller.sensors[0].positive:
    owner = controller.owner
    strength = owner.get(INTERNAL_PROPERTY_STRENGTH, STRENGTH_NORMAL)
    
    newStrength = STRENGTH_TURBO if strength &lt; STRENGTH_TURBO else STRENGTH_NORMAL
    owner[INTERNAL_PROPERTY_STRENGTH] = newStrength

move.py
import bge

controller = bge.logic.getCurrentController()

INTERNAL_PROPERTY_STRENGTH = &quot;internal.strength&quot;

STRENGTH_NORMAL = -1

if controller.sensors[0].positive:
    owner = controller.owner
    strength = owner.get(INTERNAL_PROPERTY_STRENGTH, STRENGTH_NORMAL)
    force = [0.0, 0.0, strength]
    
    owner.applyForce(force, True)


The &quot;move&quot; sensor requires [True Level Triggering] enables otherwise there will be just a single impulse rather than a constant force when the key is pressed.

Hint
Better avoid &quot;main()&quot;. It serves no purpose other than to make your code hard to read.
If you really want to place your code into a function choose a descriptive name that tells what the function is supposed to do.
When this is the only function in your script the script name should already provide this information. This should not prevent you to provide more details with the function name.
The name &quot;main&quot; is a reserved word in other programming languages for complete different purpose. It can easily create confusion when used here.
Btw. in your sample code above it cause errors.