Skip to main content
Microsoft Dynamics GP forum
Suggested answer

Key Press Capture

editSubscribe (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

  • Suggested answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,781 Super User 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
    Evelez 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
    Community Member UG Leader 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

               }

           }

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,066 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,585 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans