How to Use the Command 'screenkey' (with Examples)
- Linux
- December 17, 2024
Screenkey is an intuitive screencast tool designed to display keys as they are pressed on your screen. This can be particularly useful for creating video tutorials, teaching keyboard shortcuts, or demonstrating software usage to an audience. The program offers various functionalities, allowing you to customize the way the key presses are shown, including aspects such as position, appearance, and including mouse clicks.
Use Case 1: Displaying Keys Pressed on the Screen
Code:
screenkey
Motivation:
The primary reason for using this feature is to give a live visual display of your keyboard input. This can be invaluable when you are demonstrating software and want your audience to understand exactly what keys are being used to perform certain actions. It’s especially useful in tutorial videos or when teaching large groups via a screen share.
Explanation:
The command screenkey
without any additional parameters simply starts the application with its default settings. It will start capturing your keystrokes and display them on the screen as you type. No extra configuration is necessary, making it quick and easy to use.
Example Output:
Pressing “Ctrl+C” may be displayed on the screen as:
Ctrl+C
This real-time visualization appears usually at the bottom of the screen, helping viewers follow along effortlessly.
Use Case 2: Displaying Keys and Mouse Buttons Pressed
Code:
screenkey --mouse
Motivation:
This use case is particularly advantageous for users who wish to demonstrate both keyboard and mouse functionalities. In many software applications, the combination of keyboard shortcuts and mouse actions is essential for efficient use. By showing both inputs, you ensure a comprehensive understanding of your actions for the audience.
Explanation:
The --mouse
option extends the basic functionality of screenkey by also capturing and displaying mouse button presses. It shows clicks alongside keystrokes, providing a fuller picture of user interactions.
Example Output:
Pressing “Ctrl+S” and then clicking may be displayed as:
Ctrl+S
Mouse Button 1
This enables a clear and instructional display of the typical user actions within a software interface.
Use Case 3: Launching the Settings Menu
Code:
screenkey --show-settings
Motivation:
Sometimes users need to customize or tweak the behavior of screenkey to fit specific needs, such as changing the default font or position of the displayed keystrokes. Accessing the settings menu allows for personalizing the experience, facilitating a more tailored demonstration or tutorial.
Explanation:
The --show-settings
argument launches the configuration menu for screenkey. Here, users can adjust various preferences such as font size, colors, display duration of keys on the screen, and other settings to enhance clarity and visibility according to context.
Example Output:
Upon running the command, the settings menu will appear, offering a graphical interface for modifications.
Use Case 4: Launching Screenkey at a Specific Position
Code:
screenkey --position top|center|bottom|fixed
Motivation:
Positioning the keystroke display at a desired location on the screen can enhance visual appeal and ensure it does not overlap with important content. This level of control is crucial when producing videos or live demonstrations to maintain a clear and professional presentation.
Explanation:
The --position
flag allows you to specify where on the screen the key presses will be shown, using options such as top
, center
, bottom
, or fixed
. This provides flexibility in positioning the overlay according to the layout of your content.
Example Output:
Using --position top
, keystrokes like “Ctrl+C” may appear at the top of the screen as:
Ctrl+C
This helps in maintaining a focus on the demonstration area elsewhere on your screen.
Use Case 5: Changing the Format of the Key Modifiers Displayed
Code:
screenkey --mods-mode normal|emacs|mac|win|tux
Motivation:
Keyboards have different modifier key names depending on the operating system or text editor, such as Ctrl (Windows/Linux), Cmd (Mac), or Alt (Emacs). When you’re demonstrating a process that involves a specific type of keyboard layout or convention, adjusting this provides clear communication with your audience.
Explanation:
The --mods-mode
option lets you set the format in which modifier keys are displayed. The labels normal
, emacs
, mac
, win
, and tux
represent different keyboard conventions, adapting the on-screen display to align with your audience’s expectations or your system’s standards.
Example Output:
For a Mac layout, pressing the command key (Cmd
) may show as:
Cmd+C
This explicitly aligns the visual feedback with the operating environment, minimizing confusion.
Use Case 6: Changing the Appearance of Screenkey
Code:
screenkey --bg-color "#a1b2c3" --font Hack --font-color yellow --opacity 0.8
Motivation:
Customization of appearance is important for matching aesthetic preferences or requirements of the tutorial. Whether adapting to background colors for better legibility or aligning with branding guidelines, having control over these elements ensures optimal visibility and presentation quality.
Explanation:
--bg-color "#a1b2c3"
specifies the hexadecimal color code for the background of the keystroke overlay.--font Hack
sets the font type toHack
, a popular programming font.--font-color yellow
changes the font color to yellow for high contrast.--opacity 0.8
adjusts the transparency level, making the overlay subtly blend with the screen.
Example Output:
With the settings above, key presses like “Enter” could be displayed on a semi-transparent overlay with a blue shade background:
Enter
This customization facilitates both distinctiveness and harmony with the rest of the screen content.
Use Case 7: Selecting a Window to Display Screenkey
Code:
screenkey --position fixed --geometry $(slop -n -f '%g')
Motivation:
Sometimes it is necessary to capture key presses within a specific application or section of your screen. This is essential when demonstrating workflows that are application-specific or when focusing on a single window for instructional clarity.
Explanation:
--position fixed
sets a constant position for the key display.--geometry $(slop -n -f '%g')
uses the slop tool to let you graphically select a window or area of the screen. Theslop
command generates geometric parameters that screenkey uses to pinpoint where to show keystrokes.
Example Output:
Keys pressed while focused on a selected window, such as a terminal, will be displayed within its boundaries, emulating:
Tab
This method invisibly outlines a defined interface zone, adding focus and orientation during demonstrations.
Conclusion:
Screenkey is a versatile and highly customizable tool for screen casting keystrokes, equipped with numerous options to tailor its functionality according to specific needs. Whether you require a simple display of keystrokes or an intricate demonstration involving both keys and mouse inputs, screenkey accommodates a wide range of requirements for educational or instructional purposes.