Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP forum
Suggested answer

Key Press Capture

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 Microsoft Employee 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

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,584 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,864 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans