In the first line you create an item instance for the key.
in the second line you are getting the item info reference from the inventory.
So two things could be causing issues.
1) Your inventory does not have any item with the "Key" itemdefinition
2) the "Key" item is Unique/Mutable. In that case the item instance you created cannot be in the inventory because it is different from all other "Key" items.
I think what you are trying to do is get the item amount by item definition and not by item.
C#:
public int CheckItemExists()
{
var keyItemDefinition = InventorySystemManager.GetItemDefinition("Key");
var itemAmount = m_Inventory.GetItemAmount(keyItemDefinition);
return itemAmount;
}
Make sure you understand the difference between Item, ItemDefinition, ItemCategory, Mutable/Immutable, Unique/Common. Those documentation pages are relevant:
Item Categories are used to organize the Item Definitions. The editor allows you to create and edit your existing Item Categories. The Item Category editor . . .