Disable specific Keyboard Keys – Single Line of Code


Hey Friends,

I saw many people asking how to disable specific keys from Keyboards like for example How to Disable Enter Key , Though I never got this need 🙂 but eventually requirements has no limits hence I decided to find it out and introduce it here in my Blog.


InputFromKeyboard – System.Windows.Input.Keyboard.’PresentationCore, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35′

InputKey – System.Windows.Input.Key.’WindowsBase, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35′

Enable RunOnClient Property as Yes for both the.NET Variables

You just need to write the above code highlighted, What it will do is when the confirmation Dialogues pops up then you need to Press Yes from MOUSE instead of the Enter Key from Keyboard to execute the further piece of Codes. If you will Press Enter from Keyboard then EXIT statement will Run and system will leave the execution


13 comments on “Disable specific Keyboard Keys – Single Line of Code

  1. Pingback: Disable specific Keyboard Keys – Single Line of Code - Microsoft Dynamics NAV Community

    • Hey Mohana,

      As shown in the screenshot you need to write just below the confirm statement, as we know confirm statement will ask User to either Push Yes OR No for the further execution of codes. So if you press YES from Mouse it will execute the next piece of code but if you press YES form ENTER Key from Keyboard it wont do anything and will come out of the code due to EXIT statement. The same way you can Map anywhere whereever you need.

      Hope I made it clear.

      • Hi. Thx for informatíon. 🙂
        But where must we writte the InputFromKeyboard and InputKey code ??

      • Heu Euges,

        Just After the CONFIRM() Line of Code, as shown above in the Screenshot. InputFromKeyboard and InputKey are the two DotNet Variables.

      • Ops. I cant make a DotNet variable…
        I dont have the option as DataType.
        I have 2009 R2 NAV version.

      • Hey Eughes,

        Though NAV 2009 R2 has DotNet Variables but it will give you runtime error while executing in Classic Client. Hard Luck 🙂

        Many Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s