Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7907243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:20:45+00:00 2026-06-03T11:20:45+00:00

I have a little console application that among other things checks the status of

  • 0

I have a little console application that among other things checks the status of another operation. Once a second it checks for keypresses using Term::ReadKey. If the ‘r’ key has been pressed, it refreshes the display:

{   # generate display ...
    print "Press 'r' to refresh, any other key to exit:  ";
    my $resp = readkey();
    print $resp;
    redo if $resp =~ /r/i;
}
exit;

sub readkey {   
    my $key;
    ReadMode('cbreak');
    while (not defined $key) {
        if (defined ($key = ReadKey(-1)) ) {
            exit if $key =~ /\cC/i; # allow Ctrl-C to behave normally
            return $key;
        } else {
            sleep 1;
        }
    }
    ReadMode('normal');
}    

This all works exactly as intended. However, I also use Caffeine to keep my Win 7 display from going to sleep. This utility works by simulating a press of F15 every 59 seconds, thereby never allowing the screensaver to kick in. Although Caffeine’s approach is pretty kludgy it has worked very well for me for years. However, like Windows my console app also reads the simulated press of F15 as a real keypress, causing the console app to exit. If I could match against F15, I could filter it out. So, my question:

How can I determine if F15 has been pressed, using Term::ReadKey?

This is on Windows 7 Pro, Strawberry 5.12.3, Term::ReadKey v. 2.30.02.

(I am aware that there may be a significant x-y problem component to my question, and I welcome other solutions. However, I am curious about how one would do this. I can see why I might want to see when a function key has been pressed in other situations.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T11:20:47+00:00Added an answer on June 3, 2026 at 11:20 am

    You’re using a unix-centric module. Use a more appropriate module: Win32::Console, for example.

    You can see how to use it here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little C# console application that reads a key and checks to
I have written a little console application that uses s#arp. I can create an
I have a little console application that I'm tinkering with just to learn something
I have a little console application that has an embedded v8 engine, and I
I have been writing a little application where Form1 opens, checks that a config
I have a Windows CE console application that's entry point looks like this int
I have a little Node.js application that I'd like to hit a remote API
I have a little problem with a simple console application in which i would
We have an application that has one or more text console windows that all
I have a already compiled C++ console application wich is shown as a little

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.