Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AreCapsLocked(); not exposed to Blueprints


Building a game using Blueprints but also learning C++ at the same time. Can anybody tell me how to expose AreCapsLocked to Blueprint? It really important for my game to be able to know the current state of the Caps Lock, especially since it could be turned on before the player starts the game.


Product Version: UE 4.18
more ▼

asked Jan 09 '18 at 02:10 AM in C++ Programming

avatar image

34 3 4 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first


In order to get the current state of the Caps Lock, the AreCapsLocked() method has to be called through the current application instance. Although this instance is platform specific, Unreal Engine gives you the necessary API to check the Caps Lock state in a generic and cross-platform way. However, you would have to do a little bit of work to properly expose this method to Blueprints. Here's a step by step guide on how to make this a static BlueprintPure node that can be accessed from any blueprint:

  1. To access the running application instance, you have to first enable Slate and SlateCore modules. Open your Code Editor, go to [YourProjectName].Build.cs and either uncomment or add this line at the end of the class

     PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
  2. We're going to create a new static method within Blueprint Function Library class. You can skip to step#3 If you have already added one to your project. To create a Blueprint Function Library, go to the Editor, click on Add New > New C++ class > Scroll all the way down and select Blueprint Function Library as its parent. Let's name it MyBlueprintFunctionLibrary (a better naming convention can be something like [YourProjectName]BlueprintFunctionLibrary).

  3. In the header file, create a new static method named AreCapsLocked (or anything that makes sense) and mark it with UFUNCTION specifier BlueprintPure:

      UFUNCTION(BlueprintPure, Category = "Utilities|InputEvent")
      static bool AreCapsLocked();
  4. In the .cpp file, include the necessary headers and implement the method as such:

      #include "MyBlueprintFunctionLibrary.h"
      #include "GenericPlatform/GenericApplication.h"
      #include "SlateApplication.h"
      bool UMyBlueprintFunctionLibrary::AreCapsLocked()
          return FSlateApplication::Get().GetModifierKeys().AreCapsLocked();

There you go! Compile your code, go to any blueprint and type "CapsLock". You should now be able to see and get this node.

alt text

Hope this helps.


arecapslocked.png (13.6 kB)
more ▼

answered Jan 09 '18 at 08:41 AM

avatar image

1.5k 10 10 17

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question