Book demo Start trial

Pressing the keys

Watch this video to learn how to use the PressKey and ReleaseKey building blocks.

What you learn in this lesson

  • How to hold a key pressed while executing other building blocks.
  • How to copy a graphical element, by pressing the CTRL key while dragging the element with the mouse
  • How to release all pressed keys or release a specified key

Lesson Overview

Watch this video to learn how to use the PressKey and ReleaseKey building blocks.

What you learn in this lesson

  • How to hold a key pressed while executing other building blocks.
  • How to copy a graphical element, by pressing the CTRL key while dragging the element with the mouse
  • How to release all pressed keys or release a specified key

In this video I’ll do a short demonstration of how to use the Press Key building block.

The building block can be used if you want to hold a key pressed while performing another task using one or more building blocks.

One common example of using this is to copy graphical elements by pressing CTRL and then dragging with the mouse. This is used in most graphical interfaces, and I’m gonna show it in PowerPoint in this video.

  • Focus on PowerPoint presentation

I have a rather simple slide containing only one element. What I want to do is to copy this element a number of times by pressing CTRL and then dragging the mouse somewhere on the slide.

  • Focus on Leaptest

I’ll start by adding a Press Key building block and using the Capture functionality to add a CTRL keystroke into the text value field.

  • Add Press Key
  • Add CTRL by enabling “Capture”
  • Disable “Capture”

So when the case is running the CTRL key will be pressed when the PressKey building block is executed until we tell it to release the key. We will do this in a short while.

I then add a Drag mouse building block.

  • Add Drag Mouse

I set the start and end position directly by using the capture feature. In a normal scenario the best way to set the positions is obviously to use the Set Position or Offset Position building blocks, but for this demo I’ll accept to hard-select this.

  • Set start and end position

The third building block is a Release Key block. In this block you can specify what keys to release or just select “release all keys”.

  • Add Release Key
  • Select “release all keys”

Let’s run the case.

  • Run case

As you can see the element was copied by simply using the CTRL key and the mouse.

This ends the video.