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

  • SEARCH
  • Home
  • 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 8182539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:53:29+00:00 2026-06-07T00:53:29+00:00

In my application I allow the user to scroll a movie by holding down

  • 0

In my application I allow the user to scroll a movie by holding down the Right arrow key by using ProcessCmdKey. Now I would like to give the user the ability to increase the scrolling speed whenever desired. Ideally the user should be able to hold down the Right arrow key, then when he decides to increase the speed he should, without releasing the Right arrow key, hold down also the Shift key and when he decides to go back to the normal speed he should simply release back the Shift key. So the difference in the scrolling speed should be given only from Shift key modifier that should be added or removed to the Right arrow key pressure.

I tried a code like this but with no success (I’ve a simple label in my form in this test example):

int count = 0;
bool keyRightDown = false;

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
    if (keyData == Keys.Right)
    {
        keyRightDown = true;
        count++;
        label.Text = "count = " + count.ToString();
        return true;
    }
    if (keyData == (Keys.Shift | Keys.ShiftKey) && keyRightDown)
    {
        count += 10;
        label.Text = "count = " + count.ToString();
        return true;
    }
    return base.ProcessCmdKey(ref msg, keyData);
}

protected override bool ProcessKeyMessage(ref Message m)
{
    if ((Keys)m.WParam == Keys.Right)
    {
        if (m.Msg == 0x101) // KEYUP
        {
            keyDown = false;
            return true;
        }
    }
    return base.ProcessKeyMessage(ref m);
}

When the user add the Shift key to the Right arrow the keyData does not contain (Keys.Shift | Keys.Right) as I was expecting but (Keys.Shift | Keys.ShiftKey). However this issue can still be solved by the boolean keyRightDown. The main problem is that when the user release back the Shift key by having at this point only the Right arrow pressed, no other calls to neither ProcessCmdKey nor ProcessKeyMessage are triggered. How can I achieve my goal?

  • 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-07T00:53:30+00:00Added an answer on June 7, 2026 at 12:53 am

    The only way I found was to use a combination of calling the GetKeyState API function (user32.dll) and of a Timer. Here is as it works on the test app:

    System.Windows.Forms.Timer keyManagerTimer = new System.Windows.Forms.Timer();
    int count = 0;
    
    public Form1()
    {
        InitializeComponent();
    
        this.keyManagerTimer.Tick += (s, e) => ProcessKeys();
        this.keyManagerTimer.Interval = 25;
    }
    
    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
        if ((keyData & Keys.Right) != 0)
        {
            keyManagerTimer.Enabled = true;
            return true;
        }
        return base.ProcessCmdKey(ref msg, keyData);
    }
    
    private void ProcessKeys()
    {
        bool isShiftKeyPressed = IsKeyPressed(Keys.ShiftKey);
        bool isRightKeyPressed = IsKeyPressed(Keys.Right);
    
        if (isRightKeyPressed && !isShiftKeyPressed)
        {
            count++;
        }
        else if (isRightKeyPressed && isShiftKeyPressed)
        {
            count += 10;
        }
        label.Text = "count = " + count.ToString();
    }
    
    public static bool IsKeyPressed(Keys key)
    {
        return BitConverter.GetBytes(GetKeyState((int)key))[1] > 0;
    }
    
    [DllImport("user32")]
    private static extern short GetKeyState(int vKey);
    

    In my real code then I disable the Timer on the Leave event of the Control where I have the video. Possibly another solution might have been to use the IMessageFilter (see here).

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

Sidebar

Related Questions

In our application, we allow user's to write their Bio using a WYSIWYG editor,
I am using ShareKit to allow the user of an iPad application to Tweet
Can we allow user to set and save application data and temp data using
In my application, I would like to present the user with a full-screen photo
I'm using Oracle DB in my application My Application allow the user to create
I would like to add to my application a Tell Friend option which allow
In my web application I allow user generated content to be posted for public
In my application I have large area (≈5000x5000pts) and I must allow user to
I am downloading PDF file in my application and want to allow user to
http://f.cl.ly/items/350X3c0h0A0k3s3f1R1h/Screen%20Shot%202012-03-27%20at%202.53.41%20PM.png I'm working on an application that'll allow a user to select a range

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.