Velocity framework inputservice doesn't work properly / trying to understand contextactionservice

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to use the Velocity Framework’s inputservice to bind a hold function when it is pressed and released.

  2. What is the issue? Include screenshots / videos if possible!

local velocity = require(game.ReplicatedStorage.modules.Velocity):Init(true)
local inputs = velocity:GetService("InputService")
inputs:Bind(Enum.KeyCode.H, "Begin", function() print("pressed") end, "h press")
inputs:Bind(Enum.KeyCode.H, "End", function() print("released") end, "h release")

17:32:03.060 pressed - Client - LocalScript:4
It only prints the pressed but not the release. Although, if the bind’s name is the same, it only prints the release and not the pressed.

local velocity = require(game.ReplicatedStorage.modules.Velocity):Init(true)
local inputs = velocity:GetService("InputService")
inputs:Bind(Enum.KeyCode.H, "Begin", function() print("pressed") end, "h press")
inputs:Bind(Enum.KeyCode.H, "End", function() print("released") end, "h press")

17:31:21.228 released - Client - LocalScript:5
3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Because the module service uses ContextActionService, I tried this and it works:

local contextActionService = game:GetService("ContextActionService")
local function gHold(name, state, input)
	if state == Enum.UserInputState.Begin then
		print("g pressed")
	elseif state == Enum.UserInputState.End then
		print("g released")
	end
end
contextActionService:BindAction("gHold", gHold, false, Enum.KeyCode.G)
  17:38:17.212  g pressed  -  Client - LocalScript:10
  17:38:17.545  g released  -  Client - LocalScript:12

Here is the following service I’m using. I was trying to understand the code in why using the service wouldn’t work on both pressed and released but it seems correct to me.

local InputService = {
	Binds = {};
	ValidStates = {"Begin", "Change", "Cancel", "End", "None"};
	StatePriorities = {
		Begin = 5;
		Change = 4;	
		End = 3;
		Cancel = 2;
		None = 1;
	};
	EnabledTypes = {"Accelerometer", "Gamepad", "Gyroscope", "Keyboard", "Touch", "VR"};
}
local mc = require(script.Parent.Parent.ModuleComponents)
local ContextActionService = game:GetService("ContextActionService")
local UserInputService = game:GetService("UserInputService")

function Handle(name, state, inputObject)
	if state == Enum.UserInputState[InputService.Binds[name].State] then
		InputService.Binds[name].Func()
		for i,v in pairs(InputService.Binds) do
			print(InputService.Binds[i])
		end

	end
end

function InputService:Bind(input, state, func, name)
	mc:params({"skip", "string", "function", "string"}, {input, state, func, name}, 3)
	mc:assertf(table.find(self.ValidStates, state), "%s is not a valid state!", state)
	mc:assertf(typeof(input) == "EnumItem" or typeof(input) == "table", "%s needs to be a Input Enumeration or an array with Input Enumerations inside!", tostring(input))
	
	local name = name or "Bind_" .. mc:tCount(self.Binds)
	self.Binds[name] = {
		Name = name,
		State = state,
		Func = func,
		Input = input	
	}
	ContextActionService:BindActionAtPriority(name, Handle, false, self.StatePriorities[state],input)
	return name
end

InputService.lua (1.9 KB)

Really I can’t help you with what you’re doing since I don’t know the module, but I know another method by using input began and input ended. Although, this is not what you’re looking for hopefully if you have no other help you can use this method. Basically in UIS (User Input Service) you can detect when a player is holding or releasing a key.
Here’s a sample script:

local UserInputService = game:GetService("UserInputService")

function onInputBegan(input, gameProceed)
   if gameProceed then return end

   if input.KeyCode == Enum.KeyCode.H then
       print("H Pressed")
   end
end

function onInputEnded(input, gameProceed)
   if gameProceed then return end

   if input.KeyCode == Enum.KeyCode.H then
       print("H Released")
   end
end

-- Connect Functions
UserInputService.InputBegan:Connect(onInputBegan)
UserInputService.InputEnded:Connect(onInputEnded)

Again I know this wasn’t what you were looking for, but if you need another method for

this hopefully will help if you can’t figure out the module.