Skip to content

How to get the VK_ virtual key code constants / enum? #849

Answered by AArnott
RayKoopa asked this question in Q&A
Discussion options

You must be logged in to vote

You're very close. The syntax you're trying with VK_* successfully matches constants that begin with that prefix, which is why you're getting something, though not what you want.

If you had tried VK_RETURN itself, your compilation would produce a warning:

NativeMethods.txt(1,1,1,10): warning PInvoke004: Use the name of the enum that declares this constant: VIRTUAL_KEY

This warning only appears in the build output and not the error list till after your compile due to a roslyn bug.

Anyway, that warning gives you a clue that the constant has been elevated to an enum. You should request the enum name in NativeMethods.txt and find the constant there in your C# code.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@RayKoopa
Comment options

Answer selected by RayKoopa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants