Ejemplo n.º 1
0
        /// <summary>
        /// This methode can be used in a update function to detect if a certain key is being held down. For example:
        /// If(Input.onKeyPressed(KeyCode.Space)){
        ///     // this is called when the space bar is pressed
        /// }
        /// </summary>
        /// <param name="code"></param>
        /// <returns>Returns true or false</returns>
        public static bool onKeyPressed(KeyCode code)
        {
            keyObj key = keycodes.keys[code];

            if (key != null)
            {
                return(key.isPressed());
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This methode can be used in a update function to detect if a certain key is released. For example:
        /// If(Input.onKeyUp(KeyCode.Space)){
        ///     // this is called when the space bar is released
        /// }
        /// </summary>
        /// <param name="code"></param>
        /// <returns>Returns true or false</returns>
        public static bool onKeyUp(KeyCode code)
        {
            keyObj key = keycodes.keys[code];

            if (key != null)
            {
                bool b = key.isUp();
                if (b)
                {
                    key.waitForChange = true;
                }
                return(b);
            }
            else
            {
                return(false);
            }
        }