generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Getting exact key input

Previous Thread :: Next Thread 
mattscy is online. mattscy
Joined: 06 May 2011
Total Posts: 1079
19 Sep 2017 08:09 PM
I know how to use UserInputService to get the key the player pressed, but im unsure how to find the exact key entered. Right now I have this:

game:GetService("UserInputService").InputBegan:connect(function(key)

print(string.char(key.KeyCode.Value))

end)

however, this doesnt work for capital letters or keyboards with different layouts. How would I fix this?


Report Abuse
Em_ily is not online. Em_ily
Joined: 21 Jan 2014
Total Posts: 1708
19 Sep 2017 08:10 PM
You have to use Enum . . .
Report Abuse
LaeMVP is online. LaeMVP
Joined: 24 Jun 2013
Total Posts: 4416
19 Sep 2017 08:10 PM
print(tostring(key.KeyCode):match("%w+$"))
Report Abuse
mattscy is online. mattscy
Joined: 06 May 2011
Total Posts: 1079
19 Sep 2017 08:12 PM
I need it to work for symbols too


Report Abuse
mattscy is online. mattscy
Joined: 06 May 2011
Total Posts: 1079
19 Sep 2017 08:25 PM
for example

if the player holds shift and presses 4, the dollar sign (or whatever alternate key it is for them) will be printed

if the player is holding shift and press a letter it will give a capital, but if not it will give a lowercase

I basically need to get the key that would come up if they typed a letter into a textbox


Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
19 Sep 2017 08:30 PM
No.
Report Abuse
mattscy is online. mattscy
Joined: 06 May 2011
Total Posts: 1079
19 Sep 2017 08:34 PM
fair enough


Report Abuse
cabbler is not online. cabbler
Joined: 19 Jun 2015
Total Posts: 735
19 Sep 2017 08:37 PM
raw input does not handle uppercase stuff. you can check yourself it's not too hard
Report Abuse
NexanianStudios is online. NexanianStudios
Joined: 16 Jul 2016
Total Posts: 1109
19 Sep 2017 08:38 PM
local shiftDown = false

UIP.InputBegan:Connect(function(keycode)

if keycode.KeyCode == Enum.Keycode.Shift then

shiftDown = true

elseif keycode.KeyCode:match(%w) and shiftDown then

print("capital")

end

end)

UIP.InputEnded:Connect(function(keycode)

if keycode.KeyCode = Enum.KeyCode.Shift then

shiftDown = false

end

end

something like that
Report Abuse
mattscy is online. mattscy
Joined: 06 May 2011
Total Posts: 1079
19 Sep 2017 08:44 PM
capitalisation isnt my only problem, if you have a keyboard from a different country raw input messes up the symbols too. Will I just have to force the player to focus on a textbox, and whatever letter they type into there I record?


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image