Capture modifier key down (Alt,Ctrl etc..)

Hi all,

I have been creating a Inventory system in UMG and C++ and been trying to implement drag drop functionality and have succeeded in part as i had to implement the drag detected part in the BP and then capture the OnDrop_Implementation in C++ (I think this is the only way to implement it in 4.7? as cant generate the Drag Drop operation in C++) this all works but what i want is to display a quantity selection userwidget for splitting of the dragged item but only if a modifier key is pressed Alt in this instance. So the simple Question is : How do I detect the Alt key is pressed in my OnDrop_Implementation handler.

Another Question is that is there a easy way to deactivate all other input / action bindings when my Inventory is displayed at the moment when my inventory is displayed my left mouse click(fire weapon) still fires and maybe this ties in to my question above as I initially wanted my drag event to be left mouse button but this doesn’t work because as i suspect I am already handling the left mouse click for fire weapon so I am using right mouse button.

Any help would be greatly appreciated.

Cheers

I belive this is the function you’re looking for: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/APlayerController/IsInputKeyDown/index.html

Sample code:



void OnDrop_Implementation()
{
    if(MyPlayerController->IsInputKeyDown(EKeys::LeftAlt))
    {
        //Do something
    }
}


Hope this helps.

1 Like

Yes that’s exactly what i wanted to detect key press thank you! :slight_smile: