Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Key Press Capture

(0) ShareShare
ReportReport
Posted on by 5

Hi,

It is possible to capture when the user click an specific key (enter) in a GP window using visual studio tools?

Thanks,

EV

Categories:
  • Suggested answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,020 Most Valuable Professional on at
    RE: Key Press Capture

    If you don't want pressing enter to execute the Save button, go to User Preferences and change the Entry Key from Tab to Return.

    No need for complex code.

  • Evelez Profile Picture
    5 on at
    RE: Key Press Capture

    Hi,

    Thanks.

    I resolve it using this.

    private void SaveRecord_ValidateBeforeOriginal(object senderSystem.ComponentModel.CancelEventArgs e)

            {
           
                if (System.Windows.Input.Keyboard.IsKeyDown(Key.Return))
                {
                    e.Cancel = true;
                }
            }
    Thanks,
    EV
  • Community Member Profile Picture
    on at
    RE: Key Press Capture

    set the KeyDown event on the object you are monitoring to your 'do stuff' event.

          private void Enter_Click(object sender, System.Windows.Forms.KeyEventArgs e)

           {

               try

               {

                   var s = e.KeyValue;

                   if (s == 13) //13 is the keyvalue for the 'Enter' key

                   {

                       OK.PerformClick();  

                   }

               }

               catch (Exception err)

               {

                    stuff

               }

           }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,095 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans