Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

I've added a counterpart to the getKeyCode function called getKeyName ... #230

Open
wants to merge 1 commit into from

2 participants

@SestrenExsis

... that allows you to look up the given String name of a particular key code.

@SestrenExsis SestrenExsis I've added a counterpart to the getKeyCode function called getKeyName…
… that allows you to look up the given String name of a particular key code.
663f4a2
@IQAndreas

Nice!

One thing to think of, in case the key is not in the map (if it wasn't added with addKey()) which would be the case for several keys, including ones of foreign keyboards, the function will throw a #1009 error.

I created a similar function a while back, but added a check to see if the key was registered or not. If not, it returns a semi-ugly [key #126], but avoids the error.
IQAndreas@390e7b0#L0R165

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 28, 2012
  1. @SestrenExsis

    I've added a counterpart to the getKeyCode function called getKeyName…

    SestrenExsis authored
    … that allows you to look up the given String name of a particular key code.
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 0 deletions.
  1. +13 −0 org/flixel/system/input/Input.as
View
13 org/flixel/system/input/Input.as
@@ -145,6 +145,19 @@ package org.flixel.system.input
{
return _lookup[KeyName];
}
+
+
+ /**
+ * Look up the string name for any given key code of the key or button.
+ *
+ * @param KeyCode The <code>int</code>key code of the key or button.
+ *
+ * @return The <code>String</code> name for that key.
+ */
+ public function getKeyName(KeyCode:int):String
+ {
+ return _map[KeyCode].name;
+ }
/**
* Check to see if any keys are pressed right now.
Something went wrong with that request. Please try again.