First, you must turn cheats on in your world. Then, you do the command /gamerule keepinventory true.
Chat with our AI personalities
to keep inventory you can do /gamerule keepinventory true or /gamerule keepinventory false
/gamemode keepInventory true
you have to do /gamerule keepinventory true or /gamerule keepinventory false
Pressing 'E' will open your inventory.
Open the chest and then you will be able to drag items into the chest, in which they will then be removed from your inventory.