<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>DisplayFusion RSS: Pascal's Inkey()</title>
<atom:link href="https://www.displayfusion.com/Discussions/RSS/?TopicID=018d0824-2cbc-71fc-b83f-708dfe221b77" rel="self" type="application/rss+xml" />
<link>https://www.displayfusion.com/Discussions/RSS/?TopicID=018d0824-2cbc-71fc-b83f-708dfe221b77</link>
<description>DisplayFusion RSS: Pascal's Inkey()</description>
<lastBuildDate>Sun, 19 Apr 2026 11:40:49 GMT</lastBuildDate>
<language>en</language>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<generator>https://www.displayfusion.com/Discussions/RSS/?TopicID=018d0824-2cbc-71fc-b83f-708dfe221b77</generator>
<item>
<title>RE: Pascal's Inkey()</title>
<link>https://www.displayfusion.com/Discussions/View/pascals-inkey/?ID=018d0824-2cbc-71fc-b83f-708dfe221b77#2</link>
<pubDate>Sun, 14 Jan 2024 14:13:45 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/pascals-inkey/?ID=018d0824-2cbc-71fc-b83f-708dfe221b77#2</guid>
<category>DisplayFusion</category>
<description><![CDATA[You can try using something like this:
Code
Copy
Select All
public static class DisplayFusionFunction
{
public static void Run(IntPtr windowHandle)
{
System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew();
bool keyUsed = false;
while(sw.ElapsedMilliseconds &lt; 500)
...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
You can try using something like this:<br/>
<br/>
<div id="" class="col-md-12 BoxWrap"><div class="Box table-responsive"><a name="code" style="width:0; height:0;"></a><h2 class="TableTitle" style="border:0"><div class="TableTitleText">Code</div><div class="TitleButtons"><div class="TableTitleButton"><a href="#" onclick="return false;" data-clipboard-target="#code019da58b18a673249bcdf656f0bb41b8" class="ClipboardCopyControl"><img src="https://www.displayfusion.com/MediaCommon/SVGs/FontAwesome/clone.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;vertical-align:middle !important;width:auto;max-width:16px;height:16px;" /><span class="Text">Copy</span></a></div><div class="TableTitleButton"><a href="#" onclick="bfs.util.codeEditorSelectAll('code019da58b18a673249bcdf656f0bb41b8Js'); return false;"><img src="https://www.displayfusion.com/MediaCommon/SVGs/FontAwesome/square-check.blue.svg" style="box-sizing:border-box;position:relative;overflow:hidden;vertical-align:middle !important;width:auto;max-width:16px;height:16px;" /><span class="Text">Select All</span></a></div></div></h2><div class="TableTitleContent table-responsive"><div class="AceEditorWrapper" style="border-top:solid 1px var(--color-default-border);padding:0"><pre id="code019da58b18a673249bcdf656f0bb41b8Js" contenteditable="true" spellcheck="true" class="skiptranslate" style="width:100%; min-height:75px;">public static class DisplayFusionFunction
{
    public static void Run(IntPtr windowHandle)
    {
        System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew();
        bool keyUsed = false;
        while(sw.ElapsedMilliseconds &lt; 500)
        {
            if (BFS.Input.IsKeyDown("17"))
            {
                keyUsed = true;
                break;    // Immediately leave the loop
            }
            //BFS.General.ThreadWait(1);    // 100x takes 3.15s
            System.Threading.Thread.Sleep(1);    // 100x takes 1.55s
        }
        if (keyUsed)
        {
            BFS.Dialog.ShowTrayMessage($"Key was used after {sw.Elapsed.TotalSeconds:0.00}s");
        }
        else
        {
            BFS.Dialog.ShowTrayMessage($"Key was NOT used after {sw.Elapsed.TotalSeconds:0.00}s");
        }
    }
}</pre><textarea id="code019da58b18a673249bcdf656f0bb41b8" name="code019da58b18a673249bcdf656f0bb41b8" style="position:absolute; top:0; left:-999999px; width:1px; height:1px;"></textarea></div>
</div></div></div><br/>
<br/>
There appeared to be a lot of overhead with loops and thread sleep/wait... so I used a stopwatch object to determine actual time to wait.
</div>
]]></content:encoded>
<media:thumbnail url="https://www.displayfusion.com/Discussions/Download/?ID=018d0824-2da7-725d-83c8-09f9ce998e90"/>
</item>
<item>
<title>Pascal's Inkey()</title>
<link>https://www.displayfusion.com/Discussions/View/pascals-inkey/?ID=018d0824-2cbc-71fc-b83f-708dfe221b77</link>
<pubDate>Sun, 14 Jan 2024 13:23:25 GMT</pubDate>
<dc:creator>Binary Fortress Software</dc:creator>
<guid isPermaLink="false">https://www.displayfusion.com/Discussions/View/pascals-inkey/?ID=018d0824-2cbc-71fc-b83f-708dfe221b77</guid>
<category>DisplayFusion</category>
<description><![CDATA[I am fairly new to C# & am looking for a C# equivalent to Pascal's inkey() which captures keyboard codes during a parameter defined delay.
I have used IsKeyDown(), as in the snippet below, but for my next project I will be in a loop until a specific keypress:
BFS.Audio.SetMute(false);
BFS.Audi...]]></description>
<content:encoded><![CDATA[<div class="CTDiscussions">
I am fairly new to C# & am looking for a C# equivalent to Pascal's inkey() which captures keyboard codes during a parameter defined delay. <br/>
<br/>
I have used IsKeyDown(), as in the snippet below, but for my next project I will be in a loop until a specific keypress:<br/>
<br/>
<div class="Inline"><pre>BFS.Audio.SetMute(false);
        BFS.Audio.SetVolume(0.15m);
        BFS.DisplayFusion.RunFunction("Enable Screen Saver");
        
        if (BFS.Input.IsKeyDown("83"))
        {
            BFS.Dialog.ShowMessageInfo("Bootup No Sound");
            BFS.Audio.SetMute(true);
        }
        else
        {
            BFS.Audio.PlayWAV("C:\\Windows\\Media\\Windows Shutdown.wav");
            BFS.General.ThreadWait(500);
            BFS.DisplayFusion.RunFunction("Start Screen Saver");
            BFS.Speech.TextToSpeechWithVoice("Good Morning Joe,   System Ready,, Happy computing", "");
        }</pre></div><br/>
<br/>
I'll keep researching Stack Overload / Google, but would appreciate real-world experiences, too.<br/>
<br/>
See attachments, comments welcome.
</div>
]]></content:encoded>
<media:thumbnail url="https://www.displayfusion.com/Discussions/Download/?ID=018d0824-2da7-725d-83c8-09f9ce998e90"/>
</item>
</channel>
</rss>