Checking if DPAD button has been released?

Hi, I am pretty new to C# and Unity, and I am creating a Script from which I can check if the axes of the dpad have been pressed or or is held, the below code works for this. However I also wanted the script to realize if the button has been released after being held, Is there a way I can do this in a simple way.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Controller : MonoBehaviour {
    public float DPADVERT;
    public float DPADHOR;
    public float LAVERT;
    public float LAHOR;
    public float RAVERT;
    public float RAHOR;

    public static bool DPadUpPressed;
    public static bool DPadDownPressed;
    public static bool DPadLeftPressed;
    public static bool DPadRightPressed;
    public static bool DPadUpReleased;
    public static bool DPadDownReleased;
    public static bool DPadLeftReleased;
    public static bool DPadRightReleased;
    public static bool DPadUpHold;
    public static bool DPadDownHold;
    public static bool DPadLeftHold;
    public static bool DPadRightHold;
    public static bool DPadUpPressed2;
    public static bool DPadDownPressed2;
    public static bool DPadLeftPressed2;
    public static bool DPadRightPressed2;


    public static bool LAUpPressed;
    public static bool LADownPressed;
    public static bool LALeftPressed;
    public static bool LARightPressed;
    public static bool LAUpHold;
    public static bool LADownHold;
    public static bool LALeftHold;
    public static bool LARightHold;
    public static bool LAUpPressed2;
    public static bool LADownPressed2;
    public static bool LALeftPressed2;
    public static bool LARightPressed2;


    public static bool RAUpPressed;
    public static bool RADownPressed;
    public static bool RALeftPressed;
    public static bool RARightPressed;
    public static bool RAUpHold;
    public static bool RADownHold;
    public static bool RALeftHold;
    public static bool RARightHold;
    public static bool RAUpPressed2;
    public static bool RADownPressed2;
    public static bool RALeftPressed2;
    public static bool RARightPressed2;
    void Start () {
       
    }
   
    // Update is called once per frame
    void Update () {
         DPADVERT = Input.GetAxisRaw("DVERT");
         DPADHOR = Input.GetAxisRaw("DHOR");
         LAVERT = Input.GetAxisRaw("LAVERT");
         LAHOR = Input.GetAxisRaw("LAHOR");
         RAVERT = Input.GetAxisRaw("RAVERT");
         RAHOR = Input.GetAxisRaw("RAHOR");
        //DPAD Vertical
        if (DPADVERT==-1){
            DPadUpHold=true;
            }
        else {
            DPadUpHold=false;
            }
        if (DPADVERT==-1&&!DPadUpPressed2){
            DPadUpPressed=true;
            DPadUpPressed2=true;
        }
        else{
            DPadUpPressed=false;
        }
        if(!DPadUpPressed &&DPADVERT!=-1){
            DPadUpPressed2=false;
        }
       

        if (DPADVERT==1){
            DPadDownHold=true;
            }
        else {
            DPadDownHold=false;
            }
        if (DPADVERT==1&&!DPadDownPressed2){
            DPadDownPressed=true;
            DPadDownPressed2=true;
        }
        else{
            DPadDownPressed=false;
        }
        if(!DPadDownPressed &&DPADVERT!=1){
            DPadDownPressed2=false;
        }
       
        //DPAD Horizontal
        if (DPADHOR==-1){
            DPadLeftHold=true;
            }
        else {
            DPadLeftHold=false;
            }
        if (DPADHOR==-1&&!DPadLeftPressed2){
            DPadLeftPressed=true;
            DPadLeftPressed2=true;
        }
        else{
            DPadLeftPressed=false;
        }
        if(!DPadLeftPressed &&DPADHOR!=-1){
            DPadLeftPressed2=false;
        }
       

        if (DPADHOR==1){
            DPadRightHold=true;
            }
        else {
            DPadRightHold=false;
            }
        if (DPADHOR==1&&!DPadRightPressed2){
            DPadRightPressed=true;
            DPadRightPressed2=true;
        }
        else{
            DPadRightPressed=false;
        }
        if(!DPadRightPressed &&DPADHOR!=1){
            DPadRightPressed2=false;
        }

        //LeftAnalog Controls
        //Vertical
        //Up
        if (LAVERT==-1){
            LAUpHold=true;
            }
        else {
            LAUpHold=false;
            }
        if (LAVERT==-1&&!LAUpPressed2){
            LAUpPressed=true;
            LAUpPressed2=true;
        }
        else{
            LAUpPressed=false;
        }
        if(!LAUpPressed &&LAVERT!=-1){
            LAUpPressed2=false;
        }
        //Down
        if (LAVERT==1){
            LADownHold=true;
            }
        else {
            LADownHold=false;
            }
        if (LAVERT==-1&&!LADownPressed2){
            LADownPressed=true;
            LADownPressed2=true;
        }
        else{
            LADownPressed=false;
        }
        if(!LADownPressed &&LAVERT!=-1){
            LADownPressed2=false;
        }
        //Horizontal
        //Left
        if (LAHOR==-1){
            LALeftHold=true;
            }
        else {
            LALeftHold=false;
            }
        if (LAVERT==-1&&!LALeftPressed2){
            LALeftPressed=true;
            LALeftPressed2=true;
        }
        else{
            LALeftPressed=false;
        }
        if(!LALeftPressed &&LAVERT!=-1){
            LALeftPressed2=false;
        }
        //Right
        if (LAHOR==1){
            LARightHold=true;
            }
        else {
            LARightHold=false;
            }
        if (LAVERT==-1&&!LARightPressed2){
            LARightPressed=true;
            LARightPressed2=true;
        }
        else{
            LARightPressed=false;
        }
        if(!LARightPressed &&LAVERT!=-1){
            LARightPressed2=false;
        }
        //RightAnalog Controls
        //Vertical
        //Up
        if (RAVERT==-1){
            RAUpHold=true;
            }
        else {
            RAUpHold=false;
            }
        if (RAVERT==-1&&!RAUpPressed2){
            RAUpPressed=true;
            RAUpPressed2=true;
        }
        else{
            RAUpPressed=false;
        }
        if(!RAUpPressed &&RAVERT!=-1){
            RAUpPressed2=false;
        }
        //Down
        if (RAVERT==1){
            RADownHold=true;
            }
        else {
            RADownHold=false;
            }
        if (RAVERT==-1&&!RADownPressed2){
            RADownPressed=true;
            RADownPressed2=true;
        }
        else{
            RADownPressed=false;
        }
        if(!RADownPressed &&RAVERT!=-1){
            RADownPressed2=false;
        }
        //Horizontal
        //Left
        if (RAHOR==-1){
            RALeftHold=true;
            }
        else {
            RALeftHold=false;
            }
        if (RAVERT==-1&&!RALeftPressed2){
            RALeftPressed=true;
            RALeftPressed2=true;
        }
        else{
            RALeftPressed=false;
        }
        if(!RALeftPressed &&RAVERT!=-1){
            RALeftPressed2=false;
        }
        //Right
        if (RAHOR==1){
            RARightHold=true;
            }
        else {
            RARightHold=false;
            }
        if (RAVERT==-1&&!RARightPressed2){
            RARightPressed=true;
            RARightPressed2=true;
        }
        else{
            RARightPressed=false;
        }
        if(!RARightPressed &&RAVERT!=-1){
            RARightPressed2=false;
        }
    }
}

PS.Ignore the LA and RA variables those are for Left and Right Analog Sticks.
Also the Variables DPadUpReleased have been provided so that it becomes easier for me to understand, you may change them if you want, but do mention them.
In this code DVERT AND DHOR are the vertical and horizontal axes of the dpad respectively.
IK this code is very long but only a third of it is used for the dpad, once ik how to detect dpadbuttons being released I will use the same for LA and RA.
Sorry if this is Inconvenient and tiring to look at.

Sorry forgot to mention this, but detecting the release should be like Input.GetKeyUp(), only true the frame the button is released after being pressed.

For starters, you should be able to configure your dpad as buttons instead of axes in the input manager. This would allow you to just use Input.GetButtonUp:

If you want to handle this as an axis though, then you’re going to have to track your state frame by frame. And if it was pressed (has a value greater than some ‘deadzone’) last frame, but not pressed this frame, then it was just released.

Personally for this I use an enum to report this state difference rather than a bool. Allowing for various states:

public enum ButtonState : sbyte
{
    None = 0,
    Down = 1,
    Held = 2,
    Released = -1
}

Here is an example of how this is done using my DelegatedButtonInputSignature:

    public delegate bool ButtonDelegate();
    public delegate float AxisDelegate();

    public class DelegatedButtonInputSignature : BaseInputSignature, IButtonInputSignature
    {

        #region Fields

        private ButtonDelegate _delegate;
        private ButtonState _current;
        private ButtonState _currentFixed;
        private float _lastDown;

        #endregion

        #region CONSTRUCTOR

        public DelegatedButtonInputSignature(string id, ButtonDelegate del)
            : base(id)
        {
            _delegate = del;
        }

        #endregion

        #region Properties

        public ButtonDelegate Delegate
        {
            get { return _delegate; }
            set { _delegate = value; }
        }

        #endregion

        #region IButtonInputSignature Interface

        public ButtonState CurrentState
        {
            get
            {
                if (GameLoop.CurrentSequence == UpdateSequence.FixedUpdate)
                {
                    return _currentFixed;
                }
                else
                {
                    return _current;
                }
            }
        }

        public ButtonState GetCurrentState(bool getFixedState)
        {
            return (getFixedState) ? _currentFixed : _current;
        }

        public void Consume()
        {
            if (GameLoop.CurrentSequence == UpdateSequence.FixedUpdate)
            {
                _currentFixed = InputUtil.ConsumeButtonState(_currentFixed);
            }
            else
            {
                _current = InputUtil.ConsumeButtonState(_current);
            }
        }

        public float LastDownTime
        {
            get { return _lastDown; }
        }

        #endregion

        #region IInputSignature Interfacce

        public override void Update()
        {
            //determine based on history
            _current = InputUtil.GetNextButtonState(_current, _delegate != null ? _delegate() : false);
            if (_current == ButtonState.Down)
                _lastDown = Time.realtimeSinceStartup;
        }

        public override void FixedUpdate()
        {
            //determine based on history
            _currentFixed = InputUtil.GetNextButtonState(_currentFixed, _delegate != null ? _delegate() : false);
        }

        #endregion

    }


//inside InputUtil:
        public static ButtonState GetNextButtonState(ButtonState current, bool isButtonActive)
        {
            if (isButtonActive)
            {
                switch (current)
                {
                    case ButtonState.None:
                    case ButtonState.Released:
                        return ButtonState.Down;
                    case ButtonState.Down:
                    case ButtonState.Held:
                        return ButtonState.Held;
                }
            }
            else
            {
                switch (current)
                {
                    case ButtonState.None:
                    case ButtonState.Released:
                        return ButtonState.None;
                    case ButtonState.Down:
                    case ButtonState.Held:
                        return ButtonState.Released;
                }
            }

            return ButtonState.None;
        }

This is all taken from my SPInput library: