I always use an array and save the scan codes inside of it.
But your solution is also pretty nice, however I prefer the array because of saving/loading (just cycling through).